Prototype: Prevent a crash in Safari 1.3 on String#stripScripts and String#extractScripts. Closes #8332. Allow JSON data to contain line breaks. Closes #8271.

This commit is contained in:
Thomas Fuchs 2007-06-13 20:57:19 +00:00
parent d5665e0d22
commit 1e13c1d0b7
3 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,9 @@
*SVN*
* Prevent a crash in Safari 1.3 on String#stripScripts and String#extractScripts. Closes #8332. [grant, Tobie Langel]
* Allow JSON data to contain line breaks. Closes #8271. [pijyster, Tobie Langel]
* Add Hash.prototype.index which returns the first found property that has a specific value. Closes #8528. [Thomas Fuchs, slusarz, Mislav Marohnić]
Examples:
var hash = $H({a:1,b:'2'});

4
src/prototype.js vendored
View File

@ -18,8 +18,8 @@ var Prototype = {
document.createElement('form').__proto__)
},
ScriptFragment: '<script[^>]*>([\u0001-\uFFFF]*?)<\/script>',
JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/,
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function() { },
K: function(x) { return x }

View File

@ -417,7 +417,7 @@
}},
testEvalJSON: function() {with(this) {
var valid = '{test: "hello world!"}';
var valid = '{test: \n\r"hello world!"}';
var invalid = '{test: "hello world!"';
var dangerous = '{});attackTarget = "attack succeeded!";({}';
@ -434,9 +434,9 @@
assertRaise('SyntaxError', function(){dangerous.evalJSON(true)});
assertEqual("Not scared!", attackTarget);
assertEqual('hello world!', ('/*-secure-\n' + valid + '\n*/').evalJSON().test);
assertEqual('hello world!', ('/*-secure- \r \n ' + valid + ' \n */').evalJSON().test);
var temp = Prototype.JSONFilter;
Prototype.JSONFilter = /^\/\*(.*)\*\/$/; // test custom delimiters.
Prototype.JSONFilter = /^\/\*([\s\S]*)\*\/$/; // test custom delimiters.
assertEqual('hello world!', ('/*' + valid + '*/').evalJSON().test);
Prototype.JSONFilter = temp;
}}