Closed geographika closed 1 year ago
Can you point to the line where eval
is used? I can't find it.
Can you point to the line where
eval
is used? I can't find it.
@KaiVolland - it was an alternate approach to the one used in this pull request, and would be to simply change the line to:
return new RegExp(eval(args[1])).test(args[0] as string);
As the string is in a regex format /pattern/
this can be used by the RegExp constructor.
Closing in favour of #702
Description
A MapServer class such as in the tests here :
Converts to the following GeoStyler style (see here):
When this is converted to an OpenLayers style function using the code in OlStyleUtil
The forward slashes are escaped and no features are matched:
This pull request strips the start and trailing '\' from the string. As discussed with @jansule there may be issues if flags are stored in GeoStyler regex strings e.g.
/pattern/gmi
. To support this however would require passing'gmi'
to the flags parameter of the RegEx constructor e.g.new RegExp('pattern', 'gmi')
The following approach works for all cases
r = new RegExp(eval(args[1]))
but usingeval
is problematic. Initially I thoughtString.raw
was an option but this doesn't work correctly.Related issues or pull requests
Originally added as an issue at https://github.com/geostyler/geostyler-mapfile-parser/issues/247
Pull request type
Do you introduce a breaking change?
Checklist
npm test
locally)