Commit eb475a37 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fixing bug #78662 i.e. add proper escaping of URI when saving HTML files.

* HTMLtree.c uri.c: fixing bug #78662 i.e. add proper
  escaping of URI when saving HTML files.
* result/HTML/*: this impacted some tests
Daniel
parent 9b731d70
Sun Apr 14 23:44:58 CEST 2002 Daniel Veillard <daniel@veillard.com>
* HTMLtree.c uri.c: fixing bug #78662 i.e. add proper
escaping of URI when saving HTML files.
* result/HTML/*: this impacted some tests
Sun Apr 14 14:55:15 CEST 2002 Daniel Veillard <daniel@veillard.com>
* configure.in: trying to fix #77441
......
......@@ -26,6 +26,7 @@
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/globals.h>
#include <libxml/uri.h>
/************************************************************************
* *
......@@ -349,7 +350,23 @@ htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
value = xmlNodeListGetString(doc, cur->children, 0);
if (value) {
xmlBufferWriteChar(buf, "=");
xmlBufferWriteQuotedString(buf, value);
if ((xmlStrEqual(cur->name, BAD_CAST "href")) ||
(xmlStrEqual(cur->name, BAD_CAST "src"))) {
xmlChar *escaped;
xmlChar *tmp = value;
while (IS_BLANK(*tmp)) tmp++;
escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%");
if (escaped != NULL) {
xmlBufferWriteQuotedString(buf, escaped);
xmlFree(escaped);
} else {
xmlBufferWriteQuotedString(buf, value);
}
} else {
xmlBufferWriteQuotedString(buf, value);
}
xmlFree(value);
} else {
xmlBufferWriteChar(buf, "=\"\"");
......@@ -820,7 +837,23 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
value = xmlNodeListGetString(doc, cur->children, 0);
if (value) {
xmlOutputBufferWriteString(buf, "=");
xmlBufferWriteQuotedString(buf->buffer, value);
if ((xmlStrEqual(cur->name, BAD_CAST "href")) ||
(xmlStrEqual(cur->name, BAD_CAST "src"))) {
xmlChar *escaped;
xmlChar *tmp = value;
while (IS_BLANK(*tmp)) tmp++;
escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%");
if (escaped != NULL) {
xmlBufferWriteQuotedString(buf->buffer, escaped);
xmlFree(escaped);
} else {
xmlBufferWriteQuotedString(buf->buffer, value);
}
} else {
xmlBufferWriteQuotedString(buf->buffer, value);
}
xmlFree(value);
} else {
xmlOutputBufferWriteString(buf, "=\"\"");
......
This diff is collapsed.
This diff is collapsed.
......@@ -898,7 +898,7 @@ xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
ch = *in;
if ( (!IS_UNRESERVED(ch)) && (!xmlStrchr(list, ch)) ) {
if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!xmlStrchr(list, ch))) {
unsigned char val;
ret[out++] = '%';
val = ch >> 4;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment