Hi,
the patch was missing in my previous mail. See attachment.
Regards,
Micha
On 19.03.2014 22:26, Micha Lenk wrote:
Hi Apache developers,
In HTML you can have <div> tags that have a background image by
providing a style attribute. E.g. this can be done by something fancy
like this:
<div style="background:url(http://www.example.com/fancy-background.png)
right 0px no-repeat; height:325px;">
Currently mod_proxy_html doesn't rewrite the URL in such style
attributes (Thomas, Ewald, this is issue #22583 in our Mantis).
The attached patch tries to fix that by applying the configured string
replacements also on style attributes.
Additionally it tries to make the code a bit more readable by renaming
the function dump_content() to apply_urlmap(). This is what it actually
does, especially after the call to AP_fwrite() has been moved outside of
this function.
Please note that this patch requires the patch from issue #56284 to be
applied first. Otherwise the last chunk will not apply. The attached
patch is based on httpd trunk, rev. 1579365 plus the patch for issue
#56284 applied.
Regards,
Micha
diff --git a/modules/filters/mod_proxy_html.c b/modules/filters/mod_proxy_html.c
index 04e4ab7..12fb008 100644
--- a/modules/filters/mod_proxy_html.c
+++ b/modules/filters/mod_proxy_html.c
@@ -201,7 +201,7 @@ static void pappend(saxctxt *ctx, const char *buf, const size_t len)
ctx->offset += len;
}
-static void dump_content(saxctxt *ctx)
+static void apply_urlmap(saxctxt *ctx)
{
urlmap *m;
char *found;
@@ -281,7 +281,6 @@ static void dump_content(saxctxt *ctx)
}
}
}
- AP_fwrite(ctx, ctx->buf, strlen(ctx->buf), 1);
}
static void pcdata(void *ctxt, const xmlChar *uchars, int length)
{
@@ -338,8 +337,9 @@ static void pendElement(void *ctxt, const xmlChar *uname)
/* nah. Keeping the stack is too much overhead */
if (ctx->offset > 0) {
- dump_content(ctx);
- ctx->offset = 0; /* having dumped it, we can re-use the memory */
+ apply_urlmap(ctx);
+ AP_fwrite(ctx, ctx->buf, strlen(ctx->buf), 1);
+ ctx->offset = 0; /* having written the buffer, we can re-use it */
}
if (!desc || !desc->empty) {
ap_fprintf(ctx->f->next, ctx->bb, "</%s>", name);
@@ -628,6 +628,12 @@ static void pstartElement(void *ctxt, const xmlChar *uname,
anything that needs it in the value.
*/
ap_fputstrs(ctx->f->next, ctx->bb, " ", a[0], "=\"", NULL);
+ if (!strcasecmp(a[0], "style")) {
+ /* apply URL map on attribute value */
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, ctx->f->r,
+ "applying URLMap on style attribute value: '%s'", ctx->buf);
+ apply_urlmap(ctx);
+ }
pcharacters(ctx, (const xmlChar*)ctx->buf, strlen(ctx->buf));
ap_fputc(ctx->f->next, ctx->bb, '"');
}
@@ -1075,7 +1081,9 @@ static int proxy_css_filter(ap_filter_t *f, apr_bucket_brigade *bb)
ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, f->r, "Processing chunk: [%s]", buf_log);
// Replace matching regexps
- dump_content(fctx);
+ apply_urlmap(fctx);
+ AP_fwrite(fctx, fctx->buf, strlen(fctx->buf), 1);
+ fctx->offset = 0; /* having written the buffer, we can re-use it */
}
if (APR_BUCKET_IS_EOS(current_bucket)) {
APR_BUCKET_REMOVE(current_bucket);