michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 657367; michael@0: var summary = "eval must not parse strings containing U+2028 or U+2029"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: function esc(s) michael@0: { michael@0: return s.split("").map(function(v) michael@0: { michael@0: var code = michael@0: ("000" + v.charCodeAt(0).toString(16)).slice(-4); michael@0: return "\\u" + code; michael@0: }).join(""); michael@0: } michael@0: michael@0: try michael@0: { michael@0: var r = eval('"\u2028"'); michael@0: throw new Error("\"\\u2028\" didn't throw, returned " + esc(r)); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "U+2028 is not a valid string character"); michael@0: } michael@0: michael@0: try michael@0: { michael@0: var r = eval('("\u2028")'); michael@0: throw new Error("(\"\\u2028\") didn't throw, returned " + esc(r)); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "U+2028 is not a valid string character"); michael@0: } michael@0: michael@0: try michael@0: { michael@0: var r = eval('"\u2029"'); michael@0: throw new Error("\"\\u2029\" didn't throw, returned " + esc(r)); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "U+2029 is not a valid string character"); michael@0: } michael@0: michael@0: try michael@0: { michael@0: var r = eval('("\u2029")'); michael@0: throw new Error("(\"\\u2029\") didn't throw, returned " + esc(r)); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "U+2029 is not a valid string character"); michael@0: } michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete!");