HTML attributes handling:
- SAX.c: HTML attributes need normalization too (Bjorn Reese)
- HTMLparser.[ch]: addded htmlIsScriptAttribute()
Daniel
diff --git a/ChangeLog b/ChangeLog
index d8a50eb..4fa63f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* doc/*: rebuilt docs preparing for 2.2.5 release, added URI
diff --git a/HTMLparser.c b/HTMLparser.c
index 617b903..5750bf4 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -559,6 +559,33 @@
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 @@
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 *
diff --git a/HTMLparser.h b/HTMLparser.h
index 5d42f45..be95357 100644
--- a/HTMLparser.h
+++ b/HTMLparser.h
@@ -90,6 +90,7 @@
int *outlen,
const unsigned char* in,
int *inlen, int quoteChar);
+int htmlIsScriptAttribute(const xmlChar *name);
/**
* Interfaces for the Push mode
diff --git a/SAX.c b/SAX.c
index 25a0191..7406105 100644
--- a/SAX.c
+++ b/SAX.c
@@ -740,13 +740,12 @@
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 = NULL;
- else
- nval = xmlValidNormalizeAttributeValue(ctxt->myDoc,
- ctxt->node, fullname, value);
+ nval = xmlValidNormalizeAttributeValue(ctxt->myDoc, ctxt->node,
+ fullname, value);
if (nval != NULL)
value = nval;
diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h
index 5d42f45..be95357 100644
--- a/include/libxml/HTMLparser.h
+++ b/include/libxml/HTMLparser.h
@@ -90,6 +90,7 @@
int *outlen,
const unsigned char* in,
int *inlen, int quoteChar);
+int htmlIsScriptAttribute(const xmlChar *name);
/**
* Interfaces for the Push mode