@@ -122,34 +122,30 @@ public static String normalize(String origPath) {
122
122
// Normalize it...
123
123
if ((path != null ) && (path .length () > 0 )) {
124
124
path = path .replace ('\\' , '/' );
125
- // Remove leading '/' chars
125
+ // Remove leading '/' chars
126
126
while ((path .length () > 0 ) && (path .charAt (0 ) == '/' )) {
127
127
path = path .substring (1 );
128
128
}
129
- // Replace all double "//" with "/"
129
+ // Replace all double "//" with "/"
130
130
while (path .indexOf ("//" ) != -1 ) {
131
131
path = path .replace ("//" , "/" );
132
- }
133
- for (int idx = path .indexOf ("../" ); idx != -1 ; idx = path .indexOf ("../" )) {
132
+ }
133
+ for (int idx = path .indexOf ("/ ../" ); idx != -1 ; idx = path .indexOf ("/ ../" )) {
134
134
if (idx == 0 ) {
135
135
// Make sure we're not trying to go before the context root
136
136
LogUtil .info ("JSFT0010" , origPath );
137
137
throw new IllegalArgumentException (
138
138
"Invalid Resource Path: '" + origPath + "'" );
139
139
}
140
- if (path .charAt (idx -1 ) != '/' ) {
141
- // Not a "../" match...
142
- continue ;
143
- }
144
140
// Create new path after evaluating ".."
145
141
int prevPathIdx = path .lastIndexOf ('/' , idx -2 ) + 1 ;
146
142
path = path .substring (0 , prevPathIdx )// before x/../
147
- + path .substring (idx + 3 );// after x/../
143
+ + path .substring (idx + 4 );// after x/../
148
144
while ((path .length () > 0 ) && (path .charAt (0 ) == '/' )) {
149
145
// Remove leading '/' chars
150
146
path = path .substring (1 );
151
147
}
152
- }
148
+ }
153
149
// We check for "../" so ".." at the end of a path could occur,
154
150
// which is fine, unless it is also at the beginning...
155
151
if (path .equals (".." )) {
@@ -159,11 +155,10 @@ public static String normalize(String origPath) {
159
155
// Last ensure path does not end in a '/'
160
156
if (path .endsWith ("/" )) {
161
157
path = path .substring (0 , path .length ()-1 );
162
- }
158
+ }
163
159
}
164
-
165
160
return path ;
166
- }
161
+ }
167
162
168
163
/**
169
164
* <p> This method may be used to clean up any temporary resources. It
0 commit comments