UriUtils.extractFileExtension properly handles all fragments

Issue: SPR-15786
This commit is contained in:
Juergen Hoeller
2017-07-19 22:40:24 +02:00
parent ac1d3b22c9
commit 13080f04f4
2 changed files with 8 additions and 4 deletions

View File

@@ -336,11 +336,12 @@ public abstract class UriUtils {
@Nullable
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);