it to fix PR#25202: encoding="entity" doesn't work as advertised in
mod_include.
For backport, this'll need an ABI-preserving version that'll be
a minor MMN bump. But if we do that in /trunk/, it'll never change.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@730296
13f79535-47bb-0310-9956-
ffa450edef68
Changes with Apache 2.3.1
[ When backported to 2.2.x, remove entry from this file ]
+ *) mod_include: support generating non-ASCII characters as entities in SSI
+ PR 25202 [Nick Kew]
+
+ *) core/utils: Enhance ap_escape_html API to support escaping non-ASCII chars
+ PR 25202 [Nick Kew]
+
*) mod_rewrite: fix "B" flag breakage by reverting r5589343
PR 45529 [Bob Ionescu <bobsiegen googlemail.com>]
* 20081201.0 (2.3.0-dev) Rename several APIs to include ap_ prefix.
* 20081201.1 (2.3.0-dev) Added ap_args_to_table and ap_body_to_table.
* 20081212.0 (2.3.0-dev) Remove sb_type from process_score in scoreboard.h.
+ * 20081231.0 (2.3.0-dev) Switch ap_escape_html API: add ap_escape_html2,
+ * and make ap_escape_html a macro for it.
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
* @param s The html to escape
* @return The escaped string
*/
-AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s);
+#define ap_escape_html(p,s) ap_escape_html2(p,s,0)
+/**
+ * Escape an html string
+ * @param p The pool to allocate from
+ * @param s The html to escape
+ * @param toasc Whether to escape all non-ASCII chars to &#nnn;
+ * @return The escaped string
+ */
+AP_DECLARE(char *) ap_escape_html2(apr_pool_t *p, const char *s, int toasc);
/**
* Escape a string for logging
echo_text = ap_escape_uri(ctx->dpool, val);
break;
case E_ENTITY:
- echo_text = ap_escape_html(ctx->dpool, val);
+ /* PR#25202: escape anything non-ascii here */
+ echo_text = ap_escape_html2(ctx->dpool, val, 1);
break;
}
/* ap_escape_uri is now a macro for os_escape_path */
-AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s)
+AP_DECLARE(char *) ap_escape_html2(apr_pool_t *p, const char *s, int toasc)
{
int i, j;
char *x;
j += 4;
else if (s[i] == '"')
j += 5;
+ else if (toasc && !apr_isascii(s[i]))
+ j += 5;
if (j == 0)
return apr_pstrmemdup(p, s, i);
memcpy(&x[j], """, 6);
j += 5;
}
+ else if (toasc && !apr_isascii(s[i])) {
+ char *esc = apr_psprintf(p, "&#%3.3d;", (unsigned char)s[i]);
+ memcpy(&x[j], esc, 6);
+ j += 5;
+ }
else
x[j] = s[i];
x[j] = '\0';
return x;
}
-
AP_DECLARE(char *) ap_escape_logitem(apr_pool_t *p, const char *str)
{
char *ret;