Add Validation to Options Parameters to Prevent Handlebars Template Injection
Description
This pull request adds validation to the options parameters in the lib.js file to ensure they are parsed to the correct type and to prevent handlebars template injection. The following changes were made:
Added helper functions to parse boolean, number, and JSON values.
Validated and parsed the options parameters using the helper functions.
Threw validation errors for invalid values to prevent template injection.
Changes
Added helper functions:
parseBoolean(value, paramName)
parseNumber(value, paramName)
parseJSON(value, paramName)
Validated and parsed the following options parameters:
geojson
geojsonfile
height
width
center
zoom
maxZoom
attribution
tileserverUrl
vectorserverUrl
vectorserverToken
imagemin
oxipng
arrows
scale
markerIconOptions
style
timeout
haltOnConsoleError
Validation Requirements
Parse strings to correct types.
Throw error for invalid values.
Prevent handlebars template injection.
Testing
Manual review of the changes was conducted to ensure there are no syntax errors or obvious logical mistakes. However, there are no predefined test scripts in the project, and the README does not provide instructions for running tests. Further testing may be required to ensure the changes work as expected.
Add Validation to Options Parameters to Prevent Handlebars Template Injection
Description
This pull request adds validation to the options parameters in the
lib.js
file to ensure they are parsed to the correct type and to prevent handlebars template injection. The following changes were made:Changes
parseBoolean(value, paramName)
parseNumber(value, paramName)
parseJSON(value, paramName)
geojson
geojsonfile
height
width
center
zoom
maxZoom
attribution
tileserverUrl
vectorserverUrl
vectorserverToken
imagemin
oxipng
arrows
scale
markerIconOptions
style
timeout
haltOnConsoleError
Validation Requirements
Testing
Manual review of the changes was conducted to ensure there are no syntax errors or obvious logical mistakes. However, there are no predefined test scripts in the project, and the README does not provide instructions for running tests. Further testing may be required to ensure the changes work as expected.
Link to Devin run
https://preview.devin.ai/devin/ec2cbae217a046bb8344e2e1d3998cbb