File tree 1 file changed +14
-8
lines changed
src/main/java/de/thetaphi/forbiddenapis
1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 16
16
* limitations under the License.
17
17
*/
18
18
19
+ import java .net .URISyntaxException ;
19
20
import java .net .URL ;
20
21
import java .util .Locale ;
21
22
import java .util .regex .Pattern ;
@@ -129,16 +130,21 @@ public static String getModuleName(URL jrtUrl) {
129
130
if (!"jrt" .equalsIgnoreCase (jrtUrl .getProtocol ())) {
130
131
return null ;
131
132
}
132
- String mod = jrtUrl .getPath ();
133
- if (mod != null && mod .length () >= 1 ) {
134
- mod = mod .substring (1 );
135
- int p = mod .indexOf ('/' );
136
- if (p >= 0 ) {
137
- mod = mod .substring (0 , p );
133
+ try {
134
+ // use URI class to also decode path and remove escapes:
135
+ String mod = jrtUrl .toURI ().getPath ();
136
+ if (mod != null && mod .length () >= 1 ) {
137
+ mod = mod .substring (1 );
138
+ int p = mod .indexOf ('/' );
139
+ if (p >= 0 ) {
140
+ mod = mod .substring (0 , p );
141
+ }
142
+ return mod .isEmpty () ? null : mod ;
138
143
}
139
- return mod .isEmpty () ? null : mod ;
144
+ return null ;
145
+ } catch (URISyntaxException use ) {
146
+ return null ;
140
147
}
141
- return null ;
142
148
}
143
149
144
150
}
You can’t perform that action at this time.
0 commit comments