This commit is contained in:
acalcutt 2025-01-04 22:47:32 -05:00
parent f888286f00
commit c2f95ab2d7
2 changed files with 12 additions and 3 deletions

View file

@ -54,7 +54,10 @@ export const serve_style = {
app.get('/:id/style.json', (req, res, next) => { app.get('/:id/style.json', (req, res, next) => {
const { id } = req.params; const { id } = req.params;
if (verbose) { if (verbose) {
console.log('Handling style request for: /styles/%s/style.json', id); console.log(
'Handling style request for: /styles/%s/style.json',
String(id),
);
} }
try { try {
const item = repo[id]; const item = repo[id];

View file

@ -209,11 +209,17 @@ function getFontPbf(allowedFonts, fontPath, name, range, fallbacks) {
return reject('Invalid font name'); return reject('Invalid font name');
} }
const rangeMatch = range?.match(/^[\d-]+$/);
const sanitizedRange = rangeMatch?.[0] || 'invalid';
if (!/^\d+-\d+$/.test(range)) { if (!/^\d+-\d+$/.test(range)) {
console.error('ERROR: Invalid range: %s', range); console.error('ERROR: Invalid range: %s', sanitizedRange);
return reject('Invalid range'); return reject('Invalid range');
} }
const filename = path.join(fontPath, sanitizedName, `${range}.pbf`); const filename = path.join(
fontPath,
sanitizedName,
`${sanitizedRange}.pbf`,
);
if (!fallbacks) { if (!fallbacks) {
fallbacks = clone(allowedFonts || {}); fallbacks = clone(allowedFonts || {});
} }