isJSON unreliable for some strings
Reported by David W. Allen | August 16th, 2008 @ 12:09 AM | in 1.6.1
Some plain strings evaluate as true because of the regex on line 461.
For instance
var testAllen = "allen".isJSON()
var testFlare = "flare".isJSON()
console.assert(testAllen == false)
console.assert(testFlare == false)
Both these assertions will fail (using firebug). However, the following will all pass
var testAllen = "Allen".isJSON()
var testFlare = "Flare".isJSON()
var testRobot = "robot".isJSON()
console.assert(testAllen == false)
console.assert(testFlare == false)
console.assert(testRobot == false)
Comments and changes to this ticket
-
Juriy Zaytsev August 16th, 2008 @ 02:43 AM
- → Tag changed from to needs_patch needs_tests
- → Milestone changed from to 1.6.1
- → State changed from new to bug
- → Assigned user changed from to Juriy Zaytsev
This is a known problem which is scheduled to be fixed in 1.6.1 release. See: http://dev.rubyonrails.org/ticke...
-
Tobie Langel August 16th, 2008 @ 03:11 AM
Crockford updated the RegExp I sent him over in json2. It's planned to include it in 1.6.1.
Whether or not it solves these bugs is secondary as those aren't security issues.
The goal is to stay as close as possible to Crockford's implementation.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
