Lines Matching refs:ctx
50 url_adapt_state_ex_t *ctx;
56 ctx = &BG(url_adapt_session_ex);
58 ctx = &BG(url_adapt_output_ex);
63 if (ctx->tags)
64 zend_hash_destroy(ctx->tags);
66 ctx->tags = malloc(sizeof(HashTable));
67 if (!ctx->tags) {
73 zend_hash_init(ctx->tags, 0, NULL, tag_dtor, 1);
93 zend_hash_add_mem(ctx->tags, str, val, strlen(val)+1);
293 static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type)
299 ZSTR_VAL(ctx->arg.s)[ZSTR_LEN(ctx->arg.s)] = '\0';
300 if (!strcasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data)) {
305 smart_str_appendc(&ctx->result, type);
308 append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
310 smart_str_append_smart_str(&ctx->result, &ctx->val);
313 smart_str_appendc(&ctx->result, type);
331 #define STATE ctx->state
333 #define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR
334 #define STD_ARGS ctx, start, xp
345 smart_str_appendl(&ctx->result, start, YYCURSOR - start);
375 static int check_host_whitelist(url_adapt_state_ex_t *ctx)
378 …HashTable *allowed_hosts = ctx->type ? &BG(url_adapt_session_hosts_ht) : &BG(url_adapt_output_host…
380 ZEND_ASSERT(ctx->tag_type == TAG_FORM);
382 if (ctx->attr_val.s && ZSTR_LEN(ctx->attr_val.s)) {
383 url_parts = php_url_parse_ex(ZSTR_VAL(ctx->attr_val.s), ZSTR_LEN(ctx->attr_val.s));
424 if (ZSTR_LEN(ctx->form_app.s) > 0) {
425 switch (ZSTR_LEN(ctx->tag.s)) {
427 if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))
428 && check_host_whitelist(ctx) == SUCCESS) {
436 smart_str_append_smart_str(&ctx->result, &ctx->form_app);
452 if (ctx->tag.s) {
453 ZSTR_LEN(ctx->tag.s) = 0;
455 smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
456 for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
457 ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
459 …if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.…
461 if (ZSTR_LEN(ctx->tag.s) == sizeof("form")-1
462 && !strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))) {
463 ctx->tag_type = TAG_FORM;
465 ctx->tag_type = TAG_NORMAL;
473 if (ctx->arg.s) {
474 ZSTR_LEN(ctx->arg.s) = 0;
476 smart_str_appendl(&ctx->arg, start, YYCURSOR - start);
477 if (ctx->tag_type == TAG_FORM &&
478 strncasecmp(ZSTR_VAL(ctx->arg.s), "action", ZSTR_LEN(ctx->arg.s)) == 0) {
479 ctx->attr_type = ATTR_ACTION;
481 ctx->attr_type = ATTR_NORMAL;
487 smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
488 if (ctx->tag_type == TAG_FORM && ctx->attr_type == ATTR_ACTION) {
489 smart_str_setl(&ctx->attr_val, start + quotes, YYCURSOR - start - quotes * 2);
491 tag_arg(ctx, quotes, type);
494 static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen)
501 smart_str_appendl(&ctx->buf, newdata, newlen);
503 YYCURSOR = ZSTR_VAL(ctx->buf.s);
504 YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s);
575 …scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *Y…
578 if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest);
579 ZSTR_LEN(ctx->buf.s) = rest;
622 …_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush, url_adapt_state_ex_t *ctx)
626 xx_mainloop(ctx, src, srclen);
628 if (!ctx->result.s) {
629 smart_str_appendl(&ctx->result, "", 0);
632 *newlen = ZSTR_LEN(ctx->result.s);
634 smart_str_0(&ctx->result);
636 smart_str_append(&ctx->result, ctx->buf.s);
637 *newlen += ZSTR_LEN(ctx->buf.s);
638 smart_str_free(&ctx->buf);
639 smart_str_free(&ctx->val);
640 smart_str_free(&ctx->attr_val);
642 retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
643 smart_str_free(&ctx->result);
649 url_adapt_state_ex_t *ctx;
652 ctx = &BG(url_adapt_session_ex);
654 ctx = &BG(url_adapt_output_ex);
657 memset(ctx, 0, XtOffsetOf(url_adapt_state_ex_t, tags));
664 url_adapt_state_ex_t *ctx;
667 ctx = &BG(url_adapt_session_ex);
669 ctx = &BG(url_adapt_output_ex);
672 smart_str_free(&ctx->result);
673 smart_str_free(&ctx->buf);
674 smart_str_free(&ctx->tag);
675 smart_str_free(&ctx->arg);
676 smart_str_free(&ctx->attr_val);
700 url_adapt_state_ex_t *ctx = url_state;
701 if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) {
702 smart_str_append(&ctx->result, ctx->buf.s);
703 smart_str_appendl(&ctx->result, output, output_len);
705 *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
706 *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len;
708 smart_str_free(&ctx->buf);
709 smart_str_free(&ctx->result);