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) {
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;
and \e{in the \W{http://www.tartarus.org/}{middle} of them}, and also
\e{at the \W{http://home.att.net/~cecw/lastpage.htm}{end}}.
+Here's a hyperlink containing some special characters:
+\W{http://a<b&c>d/}{here}. (Not that it'll \e{work}, but you can at
+least determine that it's been correctly escaped by inspection of
+the output HTML.)
+
\#{FIXME: Unfortunately, we still don't quite do the right thing with
references:
How about a \e{reference to \k{subhead} here}? And at