Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: JSONDecoder does not accept string ending in \u-escape sequence #130

Open
darronschall opened this issue Jul 28, 2010 · 2 comments
Open
Labels

Comments

@darronschall
Copy link
Contributor

Originally filed by morten.barklund on 2010-01-06T10:22:16

What steps will reproduce the problem?
1a. var s:String = ""\u0040 "";
1b. var s:String = ""\u0040"";
1c. var s:String = ""\u004"";
2. new JSONDecoder(s,false).getValue()

What is the expected output?
1a. "@ "
1b. "@"
1c. JSONParseError: Unexpected end of input. Expecting 4 hex digits after \u.

What do you see instead?
1a. "@ "
1b. JSONParseError: Unexpected end of input. Expecting 4 hex digits after \u.
1c. JSONParseError: Unexpected end of input. Expecting 4 hex digits after \u.

There error is the ">=" in line 339 of JSONTokenizer in current head:
http://code.google.com/p/as3corelib/source/browse/trunk/src/com/adobe/serialization/json/JSONTokenizer.as#339

Change it to ">" and the expected results occur instead of the unexpected
error-containing results.

@darronschall
Copy link
Contributor Author

Updated by darron.schall on 2010-01-06T14:42:51

Would you be willing to submit a patch that contains the unit test to demonstrate the behavior, as well as the
correction to the line of code you indicated about?

The new unit test should show that scenario 1b is currently failing, and then after making the change to the
tokenizer the test (and all other pre-existing tests) should pass.

@darronschall
Copy link
Contributor Author

Updated by morten.barklund on 2010-01-11T15:52:36

You actually already have a test for it:

http://code.google.com/p/as3corelib/source/browse/trunk/tests/src/com/adobe/serialization/json/JSONTest.as#115

This test should fail currently. I do not have Flex Builder nor FlexUnit, so I cannot
verify with the proper setup. But if I write:

JSON.decode( ""\u0061"" )

It throws a runtime-error at me, so that test should definitely fail in any setup.

Could you please execute this test in your local setup? Maybe there is a problem with
the test-case not catching the error properly, and thus it seems like the whole
test-case works as it never asserts some false.

But in fact the function testDecodeStringWithInvalidUnicodeEscape throws an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant