diff options
Diffstat (limited to 'server/util.c')
-rw-r--r-- | server/util.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/server/util.c b/server/util.c index 3c927c23..e16b8eb2 100644 --- a/server/util.c +++ b/server/util.c @@ -1737,7 +1737,7 @@ AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partia /* 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; @@ -1750,6 +1750,8 @@ AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s) 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); @@ -1772,13 +1774,21 @@ AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s) 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_html(apr_pool_t *p, const char *s) +{ + return ap_escape_html2(p, s, 0); +} AP_DECLARE(char *) ap_escape_logitem(apr_pool_t *p, const char *str) { char *ret; |