diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp index 192d4526931d..2d18786f77b6 100644 --- a/parser/htmlparser/nsExpatDriver.cpp +++ b/parser/htmlparser/nsExpatDriver.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsExpatDriver.h" +#include "mozilla/fallible.h" #include "nsCOMPtr.h" #include "nsParserCIID.h" #include "CParserContext.h" @@ -15,6 +16,7 @@ #include "nsIUnicharInputStream.h" #include "nsIProtocolHandler.h" #include "nsNetUtil.h" +#include "nsString.h" #include "nsTextFormatter.h" #include "nsDirectoryServiceDefs.h" #include "nsCRT.h" @@ -46,6 +48,7 @@ using mozilla::fallible; using mozilla::LogLevel; using mozilla::MakeStringSpan; +using mozilla::Unused; using mozilla::dom::Document; // We only pass chunks of length sMaxChunkLength to Expat in the RLBOX sandbox. @@ -1041,12 +1044,18 @@ nsresult nsExpatDriver::HandleError() { 1; uint32_t lineNumber = RLBOX_EXPAT_SAFE_MCALL(MOZ_XML_GetCurrentLineNumber, safe_unverified); - + const XML_Char* expatBase = + RLBOX_EXPAT_MCALL(MOZ_XML_GetBase) + .copy_and_verify_address(unverified_xml_string); + nsAutoString uri; + nsCOMPtr baseURI; + if (expatBase && (baseURI = GetBaseURI(expatBase))) { + // Let's ignore if this fails, we're already reporting a parse error. + Unused << CopyUTF8toUTF16(baseURI->GetSpecOrDefault(), uri, fallible); + } nsAutoString errorText; - const auto* aBase = RLBOX_EXPAT_MCALL(MOZ_XML_GetBase) - .copy_and_verify_address(unverified_xml_string); - CreateErrorText(description.get(), aBase, lineNumber, colNumber, errorText, - spoofEnglish); + CreateErrorText(description.get(), uri.get(), lineNumber, colNumber, + errorText, spoofEnglish); nsAutoString sourceText(mLastLine); AppendErrorPointer(colNumber, mLastLine.get(), sourceText); diff --git a/parser/htmlparser/tests/mochitest/mochitest.ini b/parser/htmlparser/tests/mochitest/mochitest.ini index 05ff6f70218e..a2fa2c6c0deb 100644 --- a/parser/htmlparser/tests/mochitest/mochitest.ini +++ b/parser/htmlparser/tests/mochitest/mochitest.ini @@ -140,7 +140,8 @@ skip-if = (xorigin && debug) support-files = file_defer_bug1104732.js file_async_bug1104732.sjs - +[test_bug1752498.html] +skip-if = true # Bug 1751796 [test_compatmode.html] [test_html5_tree_construction.html] [test_html5_tree_construction_part2.html] diff --git a/parser/htmlparser/tests/mochitest/test_bug1752498.html b/parser/htmlparser/tests/mochitest/test_bug1752498.html new file mode 100644 index 000000000000..643c91049328 --- /dev/null +++ b/parser/htmlparser/tests/mochitest/test_bug1752498.html @@ -0,0 +1,32 @@ + + + + + <!-- TODO: insert title here --> + + + + + +

+ +

+
+