mirror of
https://github.com/GNOME/libxml2.git
synced 2025-10-18 00:52:00 +08:00
html: Don't escape < and > when serializing attribute values
Align with HTML5. This will break some test suites.
This commit is contained in:
24
entities.c
24
entities.c
@@ -611,18 +611,21 @@ xmlEscapeText(const xmlChar *text, int flags) {
|
|||||||
xmlChar *out;
|
xmlChar *out;
|
||||||
const xmlChar *unescaped;
|
const xmlChar *unescaped;
|
||||||
size_t size = 50;
|
size_t size = 50;
|
||||||
|
int isHtmlAttr = 0;
|
||||||
|
|
||||||
buffer = xmlMalloc(size + 1);
|
buffer = xmlMalloc(size + 1);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
out = buffer;
|
out = buffer;
|
||||||
|
|
||||||
|
if ((flags & XML_ESCAPE_HTML) && (flags & XML_ESCAPE_ATTR))
|
||||||
|
isHtmlAttr = 1;
|
||||||
|
|
||||||
cur = text;
|
cur = text;
|
||||||
unescaped = cur;
|
unescaped = cur;
|
||||||
|
|
||||||
while (*cur != '\0') {
|
while (*cur != '\0') {
|
||||||
char buf[12];
|
char buf[12];
|
||||||
const xmlChar *end;
|
|
||||||
const xmlChar *repl;
|
const xmlChar *repl;
|
||||||
size_t used;
|
size_t used;
|
||||||
size_t replSize;
|
size_t replSize;
|
||||||
@@ -649,21 +652,10 @@ xmlEscapeText(const xmlChar *text, int flags) {
|
|||||||
chunkSize = 0;
|
chunkSize = 0;
|
||||||
repl = BAD_CAST "";
|
repl = BAD_CAST "";
|
||||||
replSize = 0;
|
replSize = 0;
|
||||||
} else if (c == '<') {
|
} else if ((c == '<') && (!isHtmlAttr)) {
|
||||||
/*
|
repl = BAD_CAST "<";
|
||||||
* Special handling of server side include in HTML attributes
|
replSize = 4;
|
||||||
*/
|
} else if ((c == '>') && (!isHtmlAttr)) {
|
||||||
if ((flags & XML_ESCAPE_HTML) && (flags & XML_ESCAPE_ATTR) &&
|
|
||||||
(cur[1] == '!') && (cur[2] == '-') && (cur[3] == '-') &&
|
|
||||||
((end = xmlStrstr(cur, BAD_CAST "-->")) != NULL)) {
|
|
||||||
chunkSize = (end - cur) + 3;
|
|
||||||
repl = cur;
|
|
||||||
replSize = chunkSize;
|
|
||||||
} else {
|
|
||||||
repl = BAD_CAST "<";
|
|
||||||
replSize = 4;
|
|
||||||
}
|
|
||||||
} else if (c == '>') {
|
|
||||||
repl = BAD_CAST ">";
|
repl = BAD_CAST ">";
|
||||||
replSize = 4;
|
replSize = 4;
|
||||||
} else if (c == '&') {
|
} else if (c == '&') {
|
||||||
|
@@ -3,6 +3,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<a href="index.cgi?a&lt=1&gt=2">link</a>
|
<a href="index.cgi?a&lt=1&gt=2">link</a>
|
||||||
<a href="index.cgi?a&lta&gta">link</a>
|
<a href="index.cgi?a&lta&gta">link</a>
|
||||||
<a href="index.cgi?a<>">link</a>
|
<a href="index.cgi?a<>">link</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="Author" content="Root <root@aol.com>">
|
<meta name="Author" content="Root <root@aol.com>">
|
||||||
</head>
|
</head>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -5,6 +5,6 @@
|
|||||||
<script language="javascript">
|
<script language="javascript">
|
||||||
if (window.open<max) ;
|
if (window.open<max) ;
|
||||||
</script>
|
</script>
|
||||||
<input onclick="if(window.open<max);">
|
<input onclick="if(window.open<max);">
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
درباره من </a></span> <span class="Item">
|
درباره من </a></span> <span class="Item">
|
||||||
<a href="RSS2.asp">
|
<a href="RSS2.asp">
|
||||||
|
|
||||||
<img src="showimage.aspx?path=Files_Upload\192.png&width=%>" border="0">
|
<img src="showimage.aspx?path=Files_Upload\192.png&width=%>" border="0">
|
||||||
RSS </a></span> <span class="Item">
|
RSS </a></span> <span class="Item">
|
||||||
<a href="">
|
<a href="">
|
||||||
</a></span>
|
</a></span>
|
||||||
|
Reference in New Issue
Block a user