mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 742414 & Bug 731234 - Highlight script end tag correctly in View Source and avoid crashing when doing so. r=smaug.
This commit is contained in:
parent
cc07746d4f
commit
891bce48d7
@ -163,9 +163,7 @@ nsHtml5Highlighter::Transition(PRInt32 aState, bool aReconsume, PRInt32 aPos)
|
||||
StartSpan();
|
||||
mAmpersand = CurrentNode();
|
||||
} else {
|
||||
EndCharacters();
|
||||
StartSpan();
|
||||
mCurrentRun = CurrentNode();
|
||||
EndCharactersAndStartMarkupRun();
|
||||
}
|
||||
break;
|
||||
case NS_HTML5TOKENIZER_TAG_OPEN:
|
||||
@ -413,6 +411,8 @@ nsHtml5Highlighter::Transition(PRInt32 aState, bool aReconsume, PRInt32 aPos)
|
||||
case NS_HTML5TOKENIZER_SCRIPT_DATA_LESS_THAN_SIGN:
|
||||
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
|
||||
if (aState == NS_HTML5TOKENIZER_NON_DATA_END_TAG_NAME) {
|
||||
FlushCurrent();
|
||||
StartSpan(); // don't know if it is "end-tag" yet :-(
|
||||
break;
|
||||
}
|
||||
FinishTag();
|
||||
@ -421,8 +421,7 @@ nsHtml5Highlighter::Transition(PRInt32 aState, bool aReconsume, PRInt32 aPos)
|
||||
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED:
|
||||
case NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_DASH:
|
||||
if (aState == NS_HTML5TOKENIZER_SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN) {
|
||||
EndCharacters();
|
||||
StartSpan();
|
||||
EndCharactersAndStartMarkupRun();
|
||||
}
|
||||
break;
|
||||
// Lots of double escape states omitted, because they don't highlight.
|
||||
@ -555,12 +554,15 @@ nsHtml5Highlighter::StartCharacters()
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5Highlighter::EndCharacters()
|
||||
nsHtml5Highlighter::EndCharactersAndStartMarkupRun()
|
||||
{
|
||||
NS_PRECONDITION(mInCharacters, "Not in characters!");
|
||||
FlushChars();
|
||||
Pop();
|
||||
mInCharacters = false;
|
||||
// Now start markup run
|
||||
StartSpan();
|
||||
mCurrentRun = CurrentNode();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -204,7 +204,7 @@ class nsHtml5Highlighter
|
||||
/**
|
||||
* Ends a wrapper around a run of characters.
|
||||
*/
|
||||
void EndCharacters();
|
||||
void EndCharactersAndStartMarkupRun();
|
||||
|
||||
/**
|
||||
* Starts an <a>.
|
||||
|
4
parser/htmlparser/tests/crashtests/742414-1.html
Normal file
4
parser/htmlparser/tests/crashtests/742414-1.html
Normal file
@ -0,0 +1,4 @@
|
||||
<script></script
|
||||
><script></script
|
||||
><script></script
|
||||
>
|
@ -50,3 +50,4 @@ load 650501-1.xhtml
|
||||
load 696651-1.html
|
||||
load view-source:699347-1.xml
|
||||
load 721313-1.html
|
||||
load view-source:742414-1.html
|
||||
|
@ -7,7 +7,7 @@
|
||||
<span id></span><!--
|
||||
<span id></span>var s = "<script>foo</script>";
|
||||
<span id></span>-->
|
||||
<span id></span><span class="end-tag"></script></span><span></span><span class="comment"><!-- Not quite optimal highlight there. --></span>
|
||||
<span id></span><span></<span class="end-tag">script</span>></span><span></span><span class="comment"><!-- Comment. --></span>
|
||||
<span id></span><span><<span class="start-tag">style</span>></span>
|
||||
<span id></span>/* </foo> */
|
||||
<span id></span><span></<span class="end-tag">style</span>></span>
|
||||
|
@ -7,7 +7,7 @@ var lt = "<";
|
||||
<!--
|
||||
var s = "<script>foo</script>";
|
||||
-->
|
||||
</script><!-- Not quite optimal highlight there. -->
|
||||
</script><!-- Comment. -->
|
||||
<style>
|
||||
/* </foo> */
|
||||
</style>
|
||||
|
30
parser/htmlparser/tests/reftest/bug731234-1-ref.html
Normal file
30
parser/htmlparser/tests/reftest/bug731234-1-ref.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" class="wrap"><pre id><span class="doctype"><!DOCTYPE html></span><span>
|
||||
<span id></span></span><span><<span class="start-tag">body</span>></span><span>
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span> ></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span></<span class="end-tag">script</span>
|
||||
<span id></span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span title="End tag had attributes." class="error"></<span class="end-tag">script</span> <span class="attribute-name">foo</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span title="End tag had attributes." class="error"></<span class="end-tag">script</span> <span class="attribute-name">foo</span>=<a class="attribute-value">bar</a>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span title="End tag had attributes." class="error"></<span class="end-tag">script</span> <span class="attribute-name">foo</span>="<a class="attribute-value">bar</a>"></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- </span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- </span><span></<span class="end-tag">script</span> ></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- </span><span></<span class="end-tag">script</span>
|
||||
<span id></span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- </span><span title="End tag had attributes." class="error"></<span class="end-tag">script</span> <span class="attribute-name">foo</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- </span><span title="End tag had attributes." class="error"></<span class="end-tag">script</span> <span class="attribute-name">foo</span>=<a class="attribute-value">bar</a>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- </span><span title="End tag had attributes." class="error"></<span class="end-tag">script</span> <span class="attribute-name">foo</span>="<a class="attribute-value">bar</a>"></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- -</span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- --</span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>-- --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript> </script> </span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript> </script> --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript </script> --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript> </script > --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript> </script foo> --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript> </script foo=bar> --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span><span><<span class="start-tag">script</span>></span><span></span><span><!</span><span>--</span><span><s</span><span>cript> </script foo="bar"> --></span><span></<span class="end-tag">script</span>></span><span>X
|
||||
<span id></span></span>
|
||||
</pre>
|
||||
<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
|
27
parser/htmlparser/tests/reftest/bug731234-1.html
Normal file
27
parser/htmlparser/tests/reftest/bug731234-1.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script></script>X
|
||||
<script></script >X
|
||||
<script></script
|
||||
>X
|
||||
<script></script foo>X
|
||||
<script></script foo=bar>X
|
||||
<script></script foo="bar">X
|
||||
<script><!--</script>X
|
||||
<script><!-- </script>X
|
||||
<script><!-- </script >X
|
||||
<script><!-- </script
|
||||
>X
|
||||
<script><!-- </script foo>X
|
||||
<script><!-- </script foo=bar>X
|
||||
<script><!-- </script foo="bar">X
|
||||
<script><!-- -</script>X
|
||||
<script><!-- --</script>X
|
||||
<script><!-- --></script>X
|
||||
<script><!--<script> </script> </script>X
|
||||
<script><!--<script> </script> --></script>X
|
||||
<script><!--<script </script> --></script>X
|
||||
<script><!--<script> </script > --></script>X
|
||||
<script><!--<script> </script foo> --></script>X
|
||||
<script><!--<script> </script foo=bar> --></script>X
|
||||
<script><!--<script> </script foo="bar"> --></script>X
|
@ -19,3 +19,4 @@ fails-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated) == vi
|
||||
== bug696651-2.html bug696651-2-ref.html
|
||||
== view-source:bug700260-1.html view-source:bug700260-1-ref.html
|
||||
== view-source:bug704667-1.html bug704667-1-ref.html
|
||||
== view-source:bug731234-1.html bug731234-1-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user