[PATCH] Properly escape ampersands inside HTML attributes
Lukas Fleischer
cgit at cryptocrack.de
Tue May 24 20:38:40 CEST 2011
Ampersands ("&") appearing inside HTML attributes need to be translated
to "&". Otherwise, invalid XHTML will be generated at various
places, such as at tree views containing links to submodules.
Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
html.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/html.c b/html.c
index 4a18a57..eb1c25d 100644
--- a/html.c
+++ b/html.c
@@ -138,7 +138,7 @@ void html_attr(const char *txt)
const char *t = txt;
while(t && *t){
int c = *t;
- if (c=='<' || c=='>' || c=='\'' || c=='\"') {
+ if (c=='<' || c=='>' || c=='\'' || c=='\"' || c=='&') {
html_raw(txt, t - txt);
if (c=='>')
html(">");
@@ -148,6 +148,8 @@ void html_attr(const char *txt)
html("'");
else if (c=='"')
html(""");
+ else if (c=='&')
+ html("&");
txt = t+1;
}
t++;
--
1.7.5.2
More information about the CGit
mailing list