Bug 582940 - Make the HTML5 parser URL unescape <a name> until HTML5-compliant fragment navigation is supported. r=bzbarsky, a=blocking2.0-betaN.
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 30 Jul 2010 13:08:36 +0300
changeset 48406 8832c82d90b9a86a2f1b83dc360ae7f7f8d84cfe
parent 48405 98617b5a532b1a2efd5d0f209df7c38b4ebac2b8
child 48407 acc0e7366e538acb782c3807463c7422d1ff460b
push id14716
push userhsivonen@iki.fi
push dateFri, 30 Jul 2010 10:26:24 +0000
treeherdermozilla-central@8832c82d90b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, blocking2.0-betaN
bugs582940
milestone2.0b3pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 582940 - Make the HTML5 parser URL unescape <a name> until HTML5-compliant fragment navigation is supported. r=bzbarsky, a=blocking2.0-betaN.
parser/html/nsHtml5TreeOperation.cpp
parser/htmlparser/tests/reftest/bug582940-1-ref.html
parser/htmlparser/tests/reftest/bug582940-1.html
parser/htmlparser/tests/reftest/frame582940-ref.html
parser/htmlparser/tests/reftest/frame582940.html
parser/htmlparser/tests/reftest/reftest.list
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -55,16 +55,17 @@
 #include "nsTraceRefcnt.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIFormControl.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsIDOMDocumentType.h"
 #include "nsIMutationObserver.h"
 #include "nsIFormProcessor.h"
 #include "nsIServiceManager.h"
+#include "nsEscape.h"
 
 #ifdef MOZ_SVG
 #include "nsHtml5SVGLoadDispatcher.h"
 #endif
 
 static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
 
 /**
@@ -453,18 +454,29 @@ nsHtml5TreeOperation::Perform(nsHtml5Tre
       }
 
       PRInt32 len = attributes->getLength();
       for (PRInt32 i = len; i > 0;) {
         --i;
         // prefix doesn't need regetting. it is always null or a static atom
         // local name is never null
         nsCOMPtr<nsIAtom> localName = Reget(attributes->getLocalName(i));
-        newContent->SetAttr(attributes->getURI(i), localName, attributes->getPrefix(i), *(attributes->getValue(i)), PR_FALSE);
-        // XXX what to do with nsresult?
+        if (ns == kNameSpaceID_XHTML &&
+            nsHtml5Atoms::a == name &&
+            nsHtml5Atoms::name == localName) {
+          // This is an HTML5-incompliant Geckoism.
+          // Remove when fixing bug 582361
+          NS_ConvertUTF16toUTF8 cname(*(attributes->getValue(i)));
+          NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
+          newContent->SetAttr(attributes->getURI(i), localName,
+              attributes->getPrefix(i), uv, PR_FALSE);
+        } else {
+          newContent->SetAttr(attributes->getURI(i), localName,
+              attributes->getPrefix(i), *(attributes->getValue(i)), PR_FALSE);
+        }
       }
 
       return rv;
     }
     case eTreeOpSetFormElement: {
       nsIContent* node = *(mOne.node);
       nsIContent* parent = *(mTwo.node);
       nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(node));
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug582940-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+<script>
+function loaded() {
+  document.documentElement.removeAttribute("class");
+}
+</script>
+</head>
+<body onload='setTimeout(loaded, 10);'>
+<iframe src="frame582940-ref.html#ref"></iframe>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug582940-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+<script>
+function loaded() {
+  document.documentElement.removeAttribute("class");
+}
+</script>
+</head>
+<body onload='setTimeout(loaded, 10);'>
+<iframe src="frame582940.html#ref%20ref"></iframe>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/frame582940-ref.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+</head>
+<body>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p><a name='ref'>Ref!</a></p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/frame582940.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+</head>
+<body>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p><a name='ref%20ref'>Ref!</a></p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+</body>
+</html>
+
--- a/parser/htmlparser/tests/reftest/reftest.list
+++ b/parser/htmlparser/tests/reftest/reftest.list
@@ -1,2 +1,3 @@
 == bug566280-1.html bug566280-1-ref.html
 == bug582788-1.html bug582788-1-ref.html
+== bug582940-1.html bug582940-1-ref.html