fix(geo): remove unsafe and unnecessary new Function when parsing GeoJSON input#21640
Open
plainheart wants to merge 2 commits into
Open
fix(geo): remove unsafe and unnecessary new Function when parsing GeoJSON input#21640plainheart wants to merge 2 commits into
new Function when parsing GeoJSON input#21640plainheart wants to merge 2 commits into
Conversation
|
Thanks for your contribution! The pull request is marked to be |
There was a problem hiding this comment.
Pull request overview
This PR removes the new Function fallback used when parsing GeoJSON string inputs, addressing a reported code-execution risk in GeoJSON parsing.
Changes:
- Replace the GeoJSON string parsing fallback (
new Function(...)) with a directJSON.parse. - Fix typos in GeoJSON-related comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
163
to
165
| function parseInput(source: GeoJSONSourceInput): GeoJSON | GeoJSONCompressed { | ||
| return !isString(source) | ||
| ? source | ||
| : (typeof JSON !== 'undefined' && JSON.parse) | ||
| ? JSON.parse(source) | ||
| : (new Function('return (' + source + ');'))(); | ||
| return !isString(source) ? source : JSON.parse(source); | ||
| } |
Member
Author
There was a problem hiding this comment.
@100pah As the current codebase, do you think it is necessary to add JSON API check?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
As we discussed in the group, remove unsafe and unnecessary
new Functionwhen parsing GeoJSON input.Fixed issues
This issue was also reported as a security risk in closed #21626.
Document Info
One of the following should be checked.