1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

HTML attributes handling:

- SAX.c: HTML attributes need normalization too (Bjorn Reese)
- HTMLparser.[ch]: addded htmlIsScriptAttribute()
Daniel
This commit is contained in:
Daniel Veillard
2000-10-15 14:24:25 +00:00
parent b732a0eafc
commit 47e12f2318
5 changed files with 67 additions and 6 deletions

View File

@ -1,3 +1,8 @@
Sun Oct 15 16:21:27 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* SAX.c: HTML attributes need normalization too (Bjorn Reese)
* HTMLparser.[ch]: addded htmlIsScriptAttribute()
Sun Oct 15 13:18:36 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org> Sun Oct 15 13:18:36 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* doc/*: rebuilt docs preparing for 2.2.5 release, added URI * doc/*: rebuilt docs preparing for 2.2.5 release, added URI

View File

@ -559,6 +559,33 @@ static char *htmlNoContentElements[] = {
NULL NULL
}; };
/*
* The list of HTML attributes which are of content %Script;
* NOTE: when adding ones, check htmlIsScriptAttribute() since
* it assumes the name starts with 'on'
*/
static char *htmlScriptAttributes[] = {
"onclick",
"ondblclick",
"onmousedown",
"onmouseup",
"onmouseover",
"onmousemove",
"onmouseout",
"onkeypress",
"onkeydown",
"onkeyup",
"onload",
"onunload",
"onfocus",
"onblur",
"onsubmit",
"onrest",
"onchange",
"onselect"
};
static char** htmlStartCloseIndex[100]; static char** htmlStartCloseIndex[100];
static int htmlStartCloseIndexinitialized = 0; static int htmlStartCloseIndexinitialized = 0;
@ -896,6 +923,34 @@ htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
return(0); return(0);
} }
/**
* htmlIsScriptAttribute:
* @name: an attribute name
*
* Check if an attribute is of content type Script
*
* Returns 1 is the attribute is a script 0 otherwise
*/
int
htmlIsScriptAttribute(const xmlChar *name) {
int i;
if (name == NULL)
return(0);
/*
* all script attributes start with 'on'
*/
if ((name[0] != 'o') || (name[1] != 'n'))
return(0);
for (i = 0;
i < sizeof(htmlScriptAttributes)/sizeof(htmlScriptAttributes[0]);
i++) {
if (xmlStrEqual(name, (const xmlChar *) htmlScriptAttributes[i]))
return(1);
}
return(0);
}
/************************************************************************ /************************************************************************
* * * *
* The list of HTML predefined entities * * The list of HTML predefined entities *

View File

@ -90,6 +90,7 @@ int htmlEncodeEntities(unsigned char* out,
int *outlen, int *outlen,
const unsigned char* in, const unsigned char* in,
int *inlen, int quoteChar); int *inlen, int quoteChar);
int htmlIsScriptAttribute(const xmlChar *name);
/** /**
* Interfaces for the Push mode * Interfaces for the Push mode

11
SAX.c
View File

@ -740,13 +740,12 @@ attribute(void *ctx, const xmlChar *fullname, const xmlChar *value)
name = xmlSplitQName(ctxt, fullname, &ns); name = xmlSplitQName(ctxt, fullname, &ns);
/* /*
* Do the last stave of the attribute normalization * Do the last stage of the attribute normalization
* Needed for HTML too:
* http://www.w3.org/TR/html4/types.html#h-6.2
*/ */
if (ctxt->html) nval = xmlValidNormalizeAttributeValue(ctxt->myDoc, ctxt->node,
nval = NULL; fullname, value);
else
nval = xmlValidNormalizeAttributeValue(ctxt->myDoc,
ctxt->node, fullname, value);
if (nval != NULL) if (nval != NULL)
value = nval; value = nval;

View File

@ -90,6 +90,7 @@ int htmlEncodeEntities(unsigned char* out,
int *outlen, int *outlen,
const unsigned char* in, const unsigned char* in,
int *inlen, int quoteChar); int *inlen, int quoteChar);
int htmlIsScriptAttribute(const xmlChar *name);
/** /**
* Interfaces for the Push mode * Interfaces for the Push mode