From cb5d2792dae12a5711734da4623eb9cbecf0dfef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Wed, 30 Jan 2008 22:44:37 +0000 Subject: [PATCH] * if we find an '&', try to watch out for an ; within the next 6 chars. if we find a ';' we probably found an entity, and the URL is finished. * fixiate our endpoint by a '\0' so the other fixups don't trick us. --- webcit/html2html.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/webcit/html2html.c b/webcit/html2html.c index 893acf2a9..a695292fe 100644 --- a/webcit/html2html.c +++ b/webcit/html2html.c @@ -359,6 +359,7 @@ void output_html(char *supplied_charset, int treat_as_wiki) { /** Find the end of the link */ int strlenptr; linklen = 0; + strlenptr = strlen(ptr); for (i=0; i<=strlenptr; ++i) { if ((ptr[i]==0) @@ -371,13 +372,30 @@ void output_html(char *supplied_charset, int treat_as_wiki) { ||(ptr[i]=='>') ||(ptr[i]=='[') ||(ptr[i]==']') + ||(ptr[i]=='"') + ||(ptr[i]=='\'') ) linklen = i; + /* did s.b. send us an entity? */ + if (ptr[i] == '&') { + if ((ptr[i+2] ==';') || + (ptr[i+3] ==';') || + (ptr[i+5] ==';') || + (ptr[i+6] ==';') || + (ptr[i+7] ==';')) + linklen = i; + } if (linklen > 0) break; } if (linklen > 0) { char *ltreviewptr; char *nbspreviewptr; - //* spot for some subject strings tinymce tends to give us. + char linkedchar; + int len = linklen; + + len = linklen; + linkedchar = ptr[len]; + ptr[len] = '\0'; + /* spot for some subject strings tinymce tends to give us. */ ltreviewptr = strchr(ptr, '<'); if (ltreviewptr != NULL) { *ltreviewptr = '\0'; @@ -392,6 +410,8 @@ void output_html(char *supplied_charset, int treat_as_wiki) { if (ltreviewptr != 0) *ltreviewptr = '<'; + ptr[len] = linkedchar; + content_length += (32 + linklen); if (content_length >= converted_alloc) { converted_alloc += 8192; -- 2.30.2