@@ -492,21 +492,15 @@ private String unmapUri(String mappedUri) {
492
492
}
493
493
}
494
494
495
- Pattern SPECIAL_REGEX_CHARS = Pattern .compile ("[{}()\\ [\\ ].+*?^$\\ \\ |]" );
496
-
497
- String escapeSpecialRegexChars (String str ) {
498
- return SPECIAL_REGEX_CHARS .matcher (str ).replaceAll ("\\ \\ $0" );
499
- }
500
-
501
495
private String unmapPathUri (String mappedUri ) {
502
496
var ret = URLUtils .removeTrailingSlashes (mappedUri );
503
497
504
498
if (whatUri .equals ("*" )) {
505
499
if (!this .whereUri .equals (SLASH )) {
506
- ret = ret .replaceFirst ("^" + escapeSpecialRegexChars (this .whereUri ), "" );
500
+ ret = ret .replaceFirst ("^" + Pattern . quote (this .whereUri ), "" );
507
501
}
508
502
} else if (!this .whereUri .equals (SLASH )) {
509
- ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + escapeSpecialRegexChars (this .whereUri ), this .whatUri ));
503
+ ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + Pattern . quote (this .whereUri ), this .whatUri ));
510
504
} else {
511
505
ret = URLUtils .removeTrailingSlashes (URLUtils .removeTrailingSlashes (this .whatUri ) + ret );
512
506
}
@@ -525,11 +519,11 @@ private String unmapPathTemplateUri(String mappedUri) {
525
519
// now replace mappedUri with resolved path template
526
520
if (replacedWhatUri .equals ("*" )) {
527
521
if (!this .whereUri .equals (SLASH )) {
528
- ret = ret .replaceFirst ("^" + escapeSpecialRegexChars (rewriteUri ), "" );
522
+ ret = ret .replaceFirst ("^" + Pattern . quote (rewriteUri ), "" );
529
523
}
530
524
} else if (!this .whereUri .equals (SLASH )) {
531
525
var x = rewriteUri ;
532
- ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + escapeSpecialRegexChars (rewriteUri ), replacedWhatUri ));
526
+ ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + Pattern . quote (rewriteUri ), replacedWhatUri ));
533
527
} else {
534
528
ret = URLUtils .removeTrailingSlashes (URLUtils .removeTrailingSlashes (replacedWhatUri ) + ret );
535
529
}
@@ -561,7 +555,7 @@ private String mapPathUri(String unmappedUri) {
561
555
return this .whereUri + unmappedUri ;
562
556
}
563
557
} else {
564
- ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + escapeSpecialRegexChars (this .whatUri ), this .whereUri ));
558
+ ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + Pattern . quote (this .whatUri ), this .whereUri ));
565
559
}
566
560
567
561
if (ret .isEmpty ()) {
@@ -584,7 +578,7 @@ private String mapPathTemplateUri(String unmappedUri) {
584
578
return rewriteUri + unmappedUri ;
585
579
}
586
580
} else {
587
- ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + escapeSpecialRegexChars (replacedWhatUri ), rewriteUri ));
581
+ ret = URLUtils .removeTrailingSlashes (ret .replaceFirst ("^" + Pattern . quote (replacedWhatUri ), rewriteUri ));
588
582
}
589
583
590
584
return ret .isEmpty () ? SLASH : ret ;
0 commit comments