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

JSONTokenizer doesn't recognize all instances of Non-breaking spaces #110

Closed
darronschall opened this issue Jul 28, 2010 · 2 comments

Comments

Projects
None yet
1 participant
@darronschall
Copy link
Contributor

commented Jul 28, 2010

Originally filed by omarrr on 2009-07-29T22:19:00

Pasting into a JSON file a long string generated from the Output panel in
the Flash IDE will generate whitespaces that are not recognized by the
JSONTokenizer class. Trying to parse it will generate an exception:

[Fault] exception, information=JSONParseError: Unexpected character ' '
(code=160) encountered
Fault, parseError() at JSONTokenizer.as:544
xxx throw new JSONParseError( message, loc, jsonString );

(Note: The extra information with the charcode was added to the original code)

To fix this the following function in JSONTokenizer:

private function isWhiteSpace( ch:String ):Boolean
{
return ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' );
}

can be replaced with:

private function isWhiteSpace( ch:String ):Boolean
{
return ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ||
ch.charCodeAt(0)==160 );
}

@darronschall

This comment has been minimized.

Copy link
Contributor Author

commented Jul 28, 2010

Updated by darron.schall on 2009-08-02T20:10:32

I don't think this is a bug in the JSON parser in strict mode. According to the RFC, whitespace is defined as:

ws = *(
%x20 / ; Space
%x09 / ; Horizontal tab
%x0A / ; Line feed or New line
%x0D ; Carriage return
)

Character 160 is a non-breaking space, and not valid JSON whitespace.

However, if the parser is used in non-strict mode then I can deal with this better by including the non-
breaking space as whitespace.

Added label strict
Original ticket set status to Accepted (we converted to open)

@darronschall

This comment has been minimized.

Copy link
Contributor Author

commented Jul 28, 2010

Updated by darron.schall on 2009-08-03T00:18:47

Fixed in r93

Original ticket set status to Fixed (we converted to closed)

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.