Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/FileOps.java @ 209:f8c82fea551a
Servlet version 1.18b9 -- cleanup and bugfixes
- fixed bug with slow color JPEGs
- better pathname handling
- better filehandle cleanup (hopefully)
author | robcast |
---|---|
date | Fri, 12 Mar 2004 19:52:07 +0100 |
parents | bb4ed821d06e |
children | aaf6eace011d |
comparison
equal
deleted
inserted
replaced
208:460cd1f18b96 | 209:f8c82fea551a |
---|---|
190 // upper-dir references are unwanted | 190 // upper-dir references are unwanted |
191 if (pathname.indexOf("../") >= 0) { | 191 if (pathname.indexOf("../") >= 0) { |
192 return null; | 192 return null; |
193 } | 193 } |
194 int a = 0; | 194 int a = 0; |
195 int e = pathname.length(); | 195 int e = pathname.length() - 1; |
196 if (e < 0) { | |
197 return pathname; | |
198 } | |
196 // leading and trailing "/" are removed | 199 // leading and trailing "/" are removed |
197 if (pathname.startsWith("/")) { | 200 while ((a <= e) && (pathname.charAt(a) == '/')) { |
198 a++; | 201 a++; |
199 } | 202 } |
200 if (pathname.endsWith("/")) { | 203 while ((a < e) && (pathname.charAt(e) == '/')) { |
201 e--; | 204 e--; |
202 } | 205 } |
203 return pathname.substring(a, e); | 206 return pathname.substring(a, e + 1); |
204 } | 207 } |
205 | 208 |
206 | 209 |
207 /** | 210 /** |
208 * FileFilter for image types (helper class for getFile) | 211 * FileFilter for image types (helper class for getFile) |