Revision 3755
Added by Jing Tao over 16 years ago
src/edu/ucsb/nceas/metacat/MetaCatUtil.java | ||
---|---|---|
256 | 256 |
return optionsVector; |
257 | 257 |
} |
258 | 258 |
|
259 |
/** Normalizes the given string. Taken from configXML.java */
|
|
259 |
/** Normalizes a string read from DB. So it will be compatible to HTML */
|
|
260 | 260 |
public static String normalize(String s) |
261 | 261 |
{ |
262 | 262 |
StringBuffer str = new StringBuffer(); |
... | ... | |
292 | 292 |
} else |
293 | 293 |
// check if & is in front of amp; |
294 | 294 |
// (we dont yet check for other HTML 4.0 Character entities) |
295 |
if (i + 4 < len -1 && s.charAt(i + 1) == 'a'
|
|
295 |
if (i + 4 < len && s.charAt(i + 1) == 'a' |
|
296 | 296 |
&& s.charAt(i + 2) == 'm' |
297 | 297 |
&& s.charAt(i + 3) == 'p' |
298 | 298 |
&& s.charAt(i + 4) == ';'){ |
299 | 299 |
str.append("&"); |
300 | 300 |
i += 4; |
301 |
} else |
|
301 |
} |
|
302 |
else if (i + 3 < len && s.charAt(i + 1) == 'l' |
|
303 |
&& s.charAt(i + 2) == 't' |
|
304 |
&& s.charAt(i + 3) == ';' ){ |
|
305 |
// check if & is in front of it; |
|
306 |
str.append("<"); |
|
307 |
i += 3; |
|
308 |
} |
|
309 |
else if (i + 3 < len && s.charAt(i + 1) == 'g' |
|
310 |
&& s.charAt(i + 2) == 't' |
|
311 |
&& s.charAt(i + 3) == ';' ){ |
|
312 |
// check if & is in front of gt; |
|
313 |
// (we dont yet check for other HTML 4.0 Character entities) |
|
314 |
str.append(">"); |
|
315 |
i += 3; |
|
316 |
} |
|
317 |
else if (i + 5 < len && s.charAt(i + 1) == 'q' |
|
318 |
&& s.charAt(i + 2) == 'u' |
|
319 |
&& s.charAt(i + 3) == 'o' |
|
320 |
&& s.charAt(i + 4) == 't' |
|
321 |
&& s.charAt(i + 5) == ';') |
|
322 |
{ |
|
323 |
// check if & is in front of quot; |
|
324 |
// (we dont yet check for other HTML 4.0 Character entities) |
|
325 |
str.append("""); |
|
326 |
i += 5; |
|
327 |
} |
|
328 |
else if (i + 5 < len && s.charAt(i + 1) == 'a' |
|
329 |
&& s.charAt(i + 2) == 'p' |
|
330 |
&& s.charAt(i + 3) == 'o' |
|
331 |
&& s.charAt(i + 4) == 's' |
|
332 |
&& s.charAt(i + 5) == ';') |
|
333 |
{ |
|
334 |
// check if & is in front of apostrophe; |
|
335 |
// (we dont yet check for other HTML 4.0 Character entities) |
|
336 |
str.append("'"); |
|
337 |
i += 5; |
|
338 |
} |
|
339 |
else{ |
|
302 | 340 |
str.append("&"); |
341 |
} |
|
303 | 342 |
///////// |
304 | 343 |
break; |
305 | 344 |
} |
306 | 345 |
case '"': |
307 | 346 |
str.append("""); |
308 | 347 |
break; |
348 |
case '\'': |
|
349 |
str.append("'"); |
|
350 |
break; |
|
309 | 351 |
default: { |
310 | 352 |
if ( (ch<128) && (ch>31) ) { |
311 | 353 |
str.append(ch); |
Also available in: Unified diff
Modify normolize method by adding code to handle < > ' and "