Copilot commented on code in PR #21640:
URL: https://github.com/apache/echarts/pull/21640#discussion_r3329965371


##########
src/coord/geo/GeoJSONResource.ts:
##########
@@ -161,9 +161,5 @@ function calculateBoundingRect(regions: GeoJSONRegion[]): 
BoundingRect {
 }
 
 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);
 }

Review Comment:
   `parseInput` now calls `JSON.parse` unconditionally and lets its exceptions 
escape from the constructor. This can (1) throw a `ReferenceError` in ES3-era 
runtimes where `JSON` is not available and (2) produce 
inconsistent/less-informative error reporting compared with `_parseToRegions` 
(which wraps errors as `Invalid geoJson format`). Consider keeping the security 
fix (no `new Function`) but add a JSON availability guard and wrap `JSON.parse` 
failures with the same error prefix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to