Lines Matching refs:ctx
52 url_adapt_state_ex_t *ctx;
58 ctx = &BG(url_adapt_session_ex);
60 ctx = &BG(url_adapt_output_ex);
65 if (ctx->tags)
66 zend_hash_destroy(ctx->tags);
68 ctx->tags = malloc(sizeof(HashTable));
69 if (!ctx->tags) {
75 zend_hash_init(ctx->tags, 0, NULL, tag_dtor, 1);
95 zend_hash_add_mem(ctx->tags, str, val, strlen(val)+1);
295 static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type)
301 ZSTR_VAL(ctx->arg.s)[ZSTR_LEN(ctx->arg.s)] = '\0';
302 if (!strcasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data)) {
307 smart_str_appendc(&ctx->result, type);
310 append_modified_url(&ctx->val, &ctx->result, &ctx->url_app, PG(arg_separator).output);
312 smart_str_append_smart_str(&ctx->result, &ctx->val);
315 smart_str_appendc(&ctx->result, type);
333 #define STATE ctx->state
335 #define STD_PARA url_adapt_state_ex_t *ctx, char *start, char *YYCURSOR
336 #define STD_ARGS ctx, start, xp
347 smart_str_appendl(&ctx->result, start, YYCURSOR - start);
377 static int check_host_whitelist(url_adapt_state_ex_t *ctx)
380 …HashTable *allowed_hosts = ctx->type ? &BG(url_adapt_session_hosts_ht) : &BG(url_adapt_output_host…
382 ZEND_ASSERT(ctx->tag_type == TAG_FORM);
384 if (ctx->attr_val.s && ZSTR_LEN(ctx->attr_val.s)) {
385 url_parts = php_url_parse_ex(ZSTR_VAL(ctx->attr_val.s), ZSTR_LEN(ctx->attr_val.s));
426 if (ZSTR_LEN(ctx->form_app.s) > 0) {
427 switch (ZSTR_LEN(ctx->tag.s)) {
429 if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))
430 && check_host_whitelist(ctx) == SUCCESS) {
438 smart_str_append_smart_str(&ctx->result, &ctx->form_app);
454 if (ctx->tag.s) {
455 ZSTR_LEN(ctx->tag.s) = 0;
457 smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
458 for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++)
459 ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]);
461 …if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.…
463 if (ZSTR_LEN(ctx->tag.s) == sizeof("form")-1
464 && !strncasecmp(ZSTR_VAL(ctx->tag.s), "form", ZSTR_LEN(ctx->tag.s))) {
465 ctx->tag_type = TAG_FORM;
467 ctx->tag_type = TAG_NORMAL;
475 if (ctx->arg.s) {
476 ZSTR_LEN(ctx->arg.s) = 0;
478 smart_str_appendl(&ctx->arg, start, YYCURSOR - start);
479 if (ctx->tag_type == TAG_FORM &&
480 strncasecmp(ZSTR_VAL(ctx->arg.s), "action", ZSTR_LEN(ctx->arg.s)) == 0) {
481 ctx->attr_type = ATTR_ACTION;
483 ctx->attr_type = ATTR_NORMAL;
489 smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
490 if (ctx->tag_type == TAG_FORM && ctx->attr_type == ATTR_ACTION) {
491 smart_str_setl(&ctx->attr_val, start + quotes, YYCURSOR - start - quotes * 2);
493 tag_arg(ctx, quotes, type);
496 static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, size_t newlen)
503 smart_str_appendl(&ctx->buf, newdata, newlen);
505 YYCURSOR = ZSTR_VAL(ctx->buf.s);
506 YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s);
577 …scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *Y…
580 if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest);
581 ZSTR_LEN(ctx->buf.s) = rest;
624 …_ext(const char *src, size_t srclen, size_t *newlen, zend_bool do_flush, url_adapt_state_ex_t *ctx)
628 xx_mainloop(ctx, src, srclen);
630 if (!ctx->result.s) {
631 smart_str_appendl(&ctx->result, "", 0);
634 *newlen = ZSTR_LEN(ctx->result.s);
636 smart_str_0(&ctx->result);
638 smart_str_append(&ctx->result, ctx->buf.s);
639 *newlen += ZSTR_LEN(ctx->buf.s);
640 smart_str_free(&ctx->buf);
641 smart_str_free(&ctx->val);
642 smart_str_free(&ctx->attr_val);
644 retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
645 smart_str_free(&ctx->result);
651 url_adapt_state_ex_t *ctx;
654 ctx = &BG(url_adapt_session_ex);
656 ctx = &BG(url_adapt_output_ex);
659 memset(ctx, 0, XtOffsetOf(url_adapt_state_ex_t, tags));
666 url_adapt_state_ex_t *ctx;
669 ctx = &BG(url_adapt_session_ex);
671 ctx = &BG(url_adapt_output_ex);
674 smart_str_free(&ctx->result);
675 smart_str_free(&ctx->buf);
676 smart_str_free(&ctx->tag);
677 smart_str_free(&ctx->arg);
678 smart_str_free(&ctx->attr_val);
702 url_adapt_state_ex_t *ctx = url_state;
703 if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) {
704 smart_str_append(&ctx->result, ctx->buf.s);
705 smart_str_appendl(&ctx->result, output, output_len);
707 *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s));
708 *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len;
710 smart_str_free(&ctx->buf);
711 smart_str_free(&ctx->result);