Reviewed by Adele Peterson.
<rdar://problem/
4589530> REGRESSION: null character in JS string causes parse error (works in Tiger and in other browsers)
* kjs/lexer.cpp:
(Lexer::shift):
(Lexer::lex):
(Lexer::record16):
(Lexer::scanRegExp):
* kjs/lexer.h:
LayoutTests:
Reviewed by Adele Peterson.
Test case for:
<rdar://problem/
4620646> REGRESSION(10.4.7-10.5): can't type into editing region when creating or editing a blogger.com post
* fast/js/null-char-in-string-expected.txt: Added.
* fast/js/null-char-in-string.html: Added.
* fast/js/resources/null-char-in-string.js: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15522
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-18 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Adele Peterson.
+
+ <rdar://problem/4589530> REGRESSION: null character in JS string causes parse error (works in Tiger and in other browsers)
+
+ * kjs/lexer.cpp:
+ (Lexer::shift):
+ (Lexer::lex):
+ (Lexer::record16):
+ (Lexer::scanRegExp):
+ * kjs/lexer.h:
+
2006-07-18 Tim Omernick <timo@apple.com>
Reviewed by Tim Hatcher.
next2 = next3;
do {
if (pos >= length) {
- next3 = 0;
+ next3 = -1;
break;
}
next3 = code[pos++].uc;
} else if (current == '/' && next1 == '*') {
shift(1);
state = InMultiLineComment;
- } else if (current == 0) {
+ } else if (current == -1) {
if (!terminator && !delimited) {
// automatic semicolon insertion if program incomplete
token = ';';
if (current == stringType) {
shift(1);
setDone(String);
- } else if (current == 0 || isLineTerminator()) {
+ } else if (isLineTerminator() || current == -1) {
setDone(Bad);
} else if (current == '\\') {
state = InEscapeSequence;
setDone(Other);
} else
state = Start;
- } else if (current == 0) {
+ } else if (current == -1) {
setDone(Eof);
}
break;
case InMultiLineComment:
- if (current == 0) {
+ if (current == -1) {
setDone(Bad);
} else if (isLineTerminator()) {
nextLine();
buffer8[pos8++] = (char) c;
}
+void Lexer::record16(int c)
+{
+ ASSERT(c >= 0);
+ ASSERT(c <= USHRT_MAX);
+ record16(UChar(static_cast<unsigned short>(c)));
+}
+
void Lexer::record16(KJS::UChar c)
{
// enlarge buffer if full
bool inBrackets = false;
while (1) {
- if (isLineTerminator() || current == 0)
+ if (isLineTerminator() || current == -1)
return false;
else if (current != '/' || lastWasEscape == true || inBrackets == true)
{
private:
void record8(unsigned short c);
+ void record16(int c);
void record16(UChar c);
KJS::Identifier *makeIdentifier(UChar *buffer, unsigned int pos);
#endif
bool error;
- // current and following unicode characters
- unsigned short current, next1, next2, next3;
+ // current and following unicode characters (int to allow for -1 for end-of-file marker)
+ int current, next1, next2, next3;
UString **strings;
unsigned int numStrings;
+2006-07-18 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Adele Peterson.
+
+ Test case for:
+
+ <rdar://problem/4620646> REGRESSION(10.4.7-10.5): can't type into editing region when creating or editing a blogger.com post
+
+ * fast/js/null-char-in-string-expected.txt: Added.
+ * fast/js/null-char-in-string.html: Added.
+ * fast/js/resources/null-char-in-string.js: Added.
+
2006-07-18 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
--- /dev/null
+This test checks that null characters are allowed in JavaScript strings, rather than causing a parse error.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS String("
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/null-char-in-string.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>