Skip to content

Commit

Permalink
Update serve_style.js
Browse files Browse the repository at this point in the history
Co-Authored-By: Andrew Calcutt <[email protected]>
  • Loading branch information
acalcutt committed Dec 29, 2024
1 parent b638208 commit d635d3c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/serve_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const allowedSpriteFormats = allowedOptions(['png', 'json']);
* @returns {string} formated string for the scale or empty string if scale is invalid
*/
function allowedSpriteScales(scale) {
if (!scale) return ''; // Default to 1 if no scale provided
const match = scale.match(/(\d+)x/); // Match one or more digits before 'x'
const parsedScale = match ? parseInt(match[1], 10) : 1; // Parse the number, or default to 1 if no match
if (!scale) return '';
const match = scale.match(/(\d+)x/);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
a user-provided value
may run slow on strings with many repetitions of '0'.
const parsedScale = match ? parseInt(match[1], 10) : 1;
return '@' + Math.min(parsedScale, 3) + 'x';
}

Expand Down

0 comments on commit d635d3c

Please sign in to comment.