UriUtils.extractFileExtension properly handles all fragments

Issue: SPR-15786
(cherry picked from commit 13080f0)
This commit is contained in:
Juergen Hoeller
2017-07-19 22:40:24 +02:00
parent 4160ced64c
commit 40b4276475
2 changed files with 9 additions and 5 deletions

View File

@@ -222,11 +222,12 @@ public abstract class UriUtils {
*/
public static String extractFileExtension(String path) {
int end = path.indexOf('?');
int fragmentIndex = path.indexOf('#');
if (fragmentIndex != -1 && (end == -1 || fragmentIndex < end)) {
end = fragmentIndex;
}
if (end == -1) {
end = path.indexOf('#');
if (end == -1) {
end = path.length();
}
end = path.length();
}
int begin = path.lastIndexOf('/', end) + 1;
int paramIndex = path.indexOf(';', begin);