fix: prevent ReDoS in UriTemplate regex patterns (v1.x backport) (#1365)

This commit is contained in:
Paul Carleton 2026-01-07 14:37:11 +00:00 • committed by GitHub
commit b392f02ffc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -225,7 +225,7 @@ export class UriTemplate {
switch (part.operator) {
case '':
pattern = part.exploded ? '([^/]+(?:,[^/]+)*)' : '([^/,]+)';
pattern = part.exploded ? '([^/,]+(?:,[^/,]+)*)' : '([^/,]+)';
break;
case '+':
case '#':
@ -235,7 +235,7 @@ export class UriTemplate {
pattern = '\\.([^/,]+)';
break;
case '/':
pattern = '/' + (part.exploded ? '([^/]+(?:,[^/]+)*)' : '([^/,]+)');
pattern = '/' + (part.exploded ? '([^/,]+(?:,[^/,]+)*)' : '([^/,]+)');
break;
default:
pattern = '([^/]+)';