mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
html: Don't escape RAWTEXT and PLAINTEXT
Align with HTML5.
This commit is contained in:
@@ -499,13 +499,6 @@ htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
|
|||||||
* Name,Start Tag,End Tag,Save End,Empty,Deprecated,DTD,inline,Description
|
* Name,Start Tag,End Tag,Save End,Empty,Deprecated,DTD,inline,Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DATA_RCDATA 1
|
|
||||||
#define DATA_RAWTEXT 2
|
|
||||||
#define DATA_PLAINTEXT 3
|
|
||||||
#define DATA_SCRIPT 4
|
|
||||||
#define DATA_SCRIPT_ESC1 5
|
|
||||||
#define DATA_SCRIPT_ESC2 6
|
|
||||||
|
|
||||||
static const htmlElemDesc
|
static const htmlElemDesc
|
||||||
html40ElementTable[] = {
|
html40ElementTable[] = {
|
||||||
{ "a", 0, 0, 0, 0, 0, 0, 1, "anchor ",
|
{ "a", 0, 0, 0, 0, 0, 0, 1, "anchor ",
|
||||||
|
|||||||
19
HTMLtree.c
19
HTMLtree.c
@@ -24,6 +24,7 @@
|
|||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
|
|
||||||
#include "private/buf.h"
|
#include "private/buf.h"
|
||||||
|
#include "private/html.h"
|
||||||
#include "private/error.h"
|
#include "private/error.h"
|
||||||
#include "private/html.h"
|
#include "private/html.h"
|
||||||
#include "private/io.h"
|
#include "private/io.h"
|
||||||
@@ -714,6 +715,7 @@ htmlNodeDumpInternal(xmlOutputBufferPtr buf, xmlNodePtr cur,
|
|||||||
xmlNodePtr root, parent, metaHead = NULL;
|
xmlNodePtr root, parent, metaHead = NULL;
|
||||||
xmlAttrPtr attr;
|
xmlAttrPtr attr;
|
||||||
const htmlElemDesc * info;
|
const htmlElemDesc * info;
|
||||||
|
int isRaw = 0;
|
||||||
|
|
||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
|
|
||||||
@@ -873,6 +875,10 @@ htmlNodeDumpInternal(xmlOutputBufferPtr buf, xmlNodePtr cur,
|
|||||||
(cur->children->type != HTML_ENTITY_REF_NODE))
|
(cur->children->type != HTML_ENTITY_REF_NODE))
|
||||||
xmlOutputBufferWrite(buf, 1, "\n");
|
xmlOutputBufferWrite(buf, 1, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((info != NULL) && (info->dataMode >= DATA_RAWTEXT))
|
||||||
|
isRaw = 1;
|
||||||
|
|
||||||
parent = cur;
|
parent = cur;
|
||||||
cur = cur->children;
|
cur = cur->children;
|
||||||
continue;
|
continue;
|
||||||
@@ -898,14 +904,11 @@ htmlNodeDumpInternal(xmlOutputBufferPtr buf, xmlNodePtr cur,
|
|||||||
case HTML_TEXT_NODE:
|
case HTML_TEXT_NODE:
|
||||||
if (cur->content == NULL)
|
if (cur->content == NULL)
|
||||||
break;
|
break;
|
||||||
if (((cur->name == (const xmlChar *)xmlStringText) ||
|
if ((cur->name == (const xmlChar *)xmlStringTextNoenc) ||
|
||||||
(cur->name != (const xmlChar *)xmlStringTextNoenc)) &&
|
(isRaw)) {
|
||||||
((parent == NULL) ||
|
|
||||||
((xmlStrcasecmp(parent->name, BAD_CAST "script")) &&
|
|
||||||
(xmlStrcasecmp(parent->name, BAD_CAST "style"))))) {
|
|
||||||
xmlSerializeText(buf, cur->content, XML_ESCAPE_HTML);
|
|
||||||
} else {
|
|
||||||
xmlOutputBufferWriteString(buf, (const char *)cur->content);
|
xmlOutputBufferWriteString(buf, (const char *)cur->content);
|
||||||
|
} else {
|
||||||
|
xmlSerializeText(buf, cur->content, XML_ESCAPE_HTML);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -954,6 +957,8 @@ htmlNodeDumpInternal(xmlOutputBufferPtr buf, xmlNodePtr cur,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isRaw = 0;
|
||||||
|
|
||||||
cur = parent;
|
cur = parent;
|
||||||
/* cur->parent was validated when descending. */
|
/* cur->parent was validated when descending. */
|
||||||
parent = cur->parent;
|
parent = cur->parent;
|
||||||
|
|||||||
@@ -9,6 +9,13 @@
|
|||||||
(((c) == 0x20) || \
|
(((c) == 0x20) || \
|
||||||
(((c) >= 0x09) && ((c) <= 0x0D) && ((c) != 0x0B)))
|
(((c) >= 0x09) && ((c) <= 0x0D) && ((c) != 0x0B)))
|
||||||
|
|
||||||
|
#define DATA_RCDATA 1
|
||||||
|
#define DATA_RAWTEXT 2
|
||||||
|
#define DATA_PLAINTEXT 3
|
||||||
|
#define DATA_SCRIPT 4
|
||||||
|
#define DATA_SCRIPT_ESC1 5
|
||||||
|
#define DATA_SCRIPT_ESC2 6
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t start;
|
size_t start;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
|||||||
Reference in New Issue
Block a user