mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-06 21:49:23 +03: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;
|
||||
const xmlChar *unescaped;
|
||||
size_t size = 50;
|
||||
int isHtmlAttr = 0;
|
||||
|
||||
buffer = xmlMalloc(size + 1);
|
||||
if (buffer == NULL)
|
||||
return(NULL);
|
||||
out = buffer;
|
||||
|
||||
if ((flags & XML_ESCAPE_HTML) && (flags & XML_ESCAPE_ATTR))
|
||||
isHtmlAttr = 1;
|
||||
|
||||
cur = text;
|
||||
unescaped = cur;
|
||||
|
||||
while (*cur != '\0') {
|
||||
char buf[12];
|
||||
const xmlChar *end;
|
||||
const xmlChar *repl;
|
||||
size_t used;
|
||||
size_t replSize;
|
||||
@ -649,21 +652,10 @@ xmlEscapeText(const xmlChar *text, int flags) {
|
||||
chunkSize = 0;
|
||||
repl = BAD_CAST "";
|
||||
replSize = 0;
|
||||
} else if (c == '<') {
|
||||
/*
|
||||
* Special handling of server side include in HTML attributes
|
||||
*/
|
||||
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 == '>') {
|
||||
} else if ((c == '<') && (!isHtmlAttr)) {
|
||||
repl = BAD_CAST "<";
|
||||
replSize = 4;
|
||||
} else if ((c == '>') && (!isHtmlAttr)) {
|
||||
repl = BAD_CAST ">";
|
||||
replSize = 4;
|
||||
} else if (c == '&') {
|
||||
|
@ -3,6 +3,6 @@
|
||||
<body>
|
||||
<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<>">link</a>
|
||||
<a href="index.cgi?a<>">link</a>
|
||||
</body>
|
||||
</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">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="Author" content="Root <root@aol.com>">
|
||||
<meta name="Author" content="Root <root@aol.com>">
|
||||
</head>
|
||||
</html>
|
||||
|
@ -5,6 +5,6 @@
|
||||
<script language="javascript">
|
||||
if (window.open<max) ;
|
||||
</script>
|
||||
<input onclick="if(window.open<max);">
|
||||
<input onclick="if(window.open<max);">
|
||||
</body>
|
||||
</html>
|
||||
|
@ -43,7 +43,7 @@
|
||||
درباره من </a></span> <span class="Item">
|
||||
<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">
|
||||
<a href="">
|
||||
</a></span>
|
||||
|
Reference in New Issue
Block a user