diff options
| author | Simon Tatham <anakin@pobox.com> | 2009-11-10 19:03:11 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2009-11-10 19:03:11 +0000 |
| commit | 158f066876fea5e0b64919db5ca1f74ea7ad82db (patch) | |
| tree | cb8ff83980fc4a388b74017dad0479d4405dc8fb /bk_html.c | |
| parent | 6c481aff452a0eed147fc73144b461fe7c263d9e (diff) | |
| download | halibut-158f066876fea5e0b64919db5ca1f74ea7ad82db.zip halibut-158f066876fea5e0b64919db5ca1f74ea7ad82db.tar.gz halibut-158f066876fea5e0b64919db5ca1f74ea7ad82db.tar.bz2 halibut-158f066876fea5e0b64919db5ca1f74ea7ad82db.tar.xz | |
Escape &<> when they appear in href text.
[originally from svn r8743]
Diffstat (limited to 'bk_html.c')
| -rw-r--r-- | bk_html.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -2176,7 +2176,7 @@ static void html_words(htmloutput *ho, word *words, int flags, htmlfile *file, keywordlist *keywords, htmlconfig *cfg) { word *w; - char *c; + char *c, *c2, *p, *q; int style, type; for (w = words; w; w = w->next) switch (w->type) { @@ -2184,7 +2184,20 @@ static void html_words(htmloutput *ho, word *words, int flags, if (flags & LINKS) { element_open(ho, "a"); c = utoa_dup(w->text, CS_ASCII); - element_attr(ho, "href", c); + c2 = snewn(1 + 10*strlen(c), char); + for (p = c, q = c2; *p; p++) { + if (*p == '&') + q += sprintf(q, "&"); + else if (*p == '<') + q += sprintf(q, "<"); + else if (*p == '>') + q += sprintf(q, ">"); + else + *q++ = *p; + } + *q = '\0'; + element_attr(ho, "href", c2); + sfree(c2); sfree(c); } break; |