Commit f1da4d5c authored by Eric Lawrence's avatar Eric Lawrence Committed by Chromium LUCI CQ

Fix XSLT processing of documents over 64kb

https://crrev.com/573558 accidentally reversed the polarity of a test
such that loading of an XML document by the XSLT processor would stop
if a chunk parsed successfully instead of stopping if the chunk failed
to parse.

This CL corrects the break condition.

Bug: 1165774
Change-Id: Ic37c7f9939e1357bf816810f23169603c43cdd60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625089
Commit-Queue: Eric Lawrence [MSFT] <ericlaw@microsoft.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843104}
parent 753973e2
...@@ -137,7 +137,8 @@ static xmlDocPtr DocLoaderFunc(const xmlChar* uri, ...@@ -137,7 +137,8 @@ static xmlDocPtr DocLoaderFunc(const xmlChar* uri,
size_t offset = 0; size_t offset = 0;
for (const auto& span : *data) { for (const auto& span : *data) {
bool final_chunk = offset + span.size() == data->size(); bool final_chunk = offset + span.size() == data->size();
if (!xmlParseChunk(ctx, span.data(), static_cast<int>(span.size()), // Stop parsing chunks if xmlParseChunk returns an error.
if (xmlParseChunk(ctx, span.data(), static_cast<int>(span.size()),
final_chunk)) final_chunk))
break; break;
offset += span.size(); offset += span.size();
......
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="document-function-large.xsl"?>
<doc>
<para>Test for https://crbug.com/1165774; ensure that XML documents larger than 64kb are transformed properly.</para>
</doc>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="items" select="document('resources/larger-than-64kb-document.xml')/doc/listitem"/>
<xsl:template match="/">
<html>
<script>
if (window.testRunner) testRunner.dumpAsText();
if (5 == <xsl:value-of select="count($items)"/>)
document.write("PASS: ");
else
document.write("FAIL, expected 5 got: ");
</script>
<xsl:value-of select="count($items)"/> items.
</html>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment