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

Disallow invalid escape sequences in JSON.parse #66170

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

RedMser
Copy link
Contributor

@RedMser RedMser commented Sep 20, 2022

Part of #66114

According to the JSON specs, following is the definition of a character:

char
    any-Unicode-character-
        except-"-or-\-or-
        control-character
    \"
    \\
    \/
    \b
    \f
    \n
    \r
    \t
    \u four-hex-digits 

So any unlisted backslash escape will now cause a parsing error, instead of being silently accepted.

Add unit tests to ensure this behavior.

@RedMser RedMser requested a review from a team as a code owner September 20, 2022 16:32
@akien-mga akien-mga added bug topic:core cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Sep 20, 2022
@akien-mga akien-mga added this to the 4.0 milestone Sep 20, 2022
@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Sep 20, 2022
@akien-mga akien-mga modified the milestones: 4.0, 4.1 Feb 13, 2023
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay reviewing.

Seems fine to me, though this probably needs testing to ensure that it won't break user expectations somewhat. A bit late for this in the 4.1 release cycle so let's merge for 4.2 early on.

Could be good to add more unit tests to validate this behavior.

@akien-mga akien-mga modified the milestones: 4.1, 4.2 Jun 19, 2023
@RedMser RedMser force-pushed the json-fix-invalid-escapes branch from db9765f to cb0be11 Compare June 30, 2023 19:02
@RedMser RedMser requested a review from a team as a code owner June 30, 2023 19:02
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

tests/core/io/test_json.h Show resolved Hide resolved
@RedMser RedMser force-pushed the json-fix-invalid-escapes branch from cb0be11 to c1b7747 Compare June 30, 2023 19:23
@RedMser RedMser force-pushed the json-fix-invalid-escapes branch from c1b7747 to 427b293 Compare June 30, 2023 19:28
@YuriSizov YuriSizov merged commit f6d568b into godotengine:master Jul 12, 2023
@YuriSizov
Copy link
Contributor

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants