mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-01 09:41:47 +03:00
HTML attributes handling:
- SAX.c: HTML attributes need normalization too (Bjorn Reese) - HTMLparser.[ch]: addded htmlIsScriptAttribute() Daniel
This commit is contained in:
55
HTMLparser.c
55
HTMLparser.c
@ -559,6 +559,33 @@ static char *htmlNoContentElements[] = {
|
||||
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 int htmlStartCloseIndexinitialized = 0;
|
||||
|
||||
@ -896,6 +923,34 @@ htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
|
||||
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 *
|
||||
|
Reference in New Issue
Block a user