<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - JS parser incorrectly handles invalid utf8 in error messages."
href="https://bugs.webkit.org/show_bug.cgi?id=158128">158128</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>JS parser incorrectly handles invalid utf8 in error messages.
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Nightly Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>OS</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>EasyFix, HasReduction, NeedsRadar
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>JavaScriptCore
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>oliver@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>ggaren@apple.com, msaboff@apple.com, sbarati@apple.com
</td>
</tr></table>
<p>
<div>
<pre>The bug occurs with an input like this:
eval('({m("\udeaf")})');
The initial parsing of this results in the \udeaf escape being converted to an actual literal. This is correct.
eval then parses that string, which results in a parse error while parsing the parameter list (string literals aren't valid parameter names).
The bug occurs when we try to actually set the error message:
failWithMessage("Expected a parameter pattern or a ')' in parameter list");
This tries to produce an error message that includes the bogus token:
Exception: SyntaxError: Unexpected string literal "<The failing token>". Expected a parameter pattern or a ')' in parameter list.
This string is produced via concatenation in PrintStringStream (or whatever it's called), which calls fromUTF8() on the buffer, because \udeaf isn't a valid utf8 sequence fromUTF8 fails and returns String().
The parser then checks the error state by checking errorMessage.isNull(), which it now is. This leads to the parser continuing in a bogus state and subsequently crashing.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>