1 package org.apache.turbine.util; 2 3 18 19 import org.apache.ecs.Entities; 20 21 import org.apache.ecs.filter.CharacterFilter; 22 23 31 32 public abstract class InputFilterUtils 33 { 34 35 private static final CharacterFilter filter = htmlFilter(); 36 37 38 private static final CharacterFilter minFilter = htmlMinFilter(); 39 40 48 public static String prepareText(String s) 49 { 50 return filter.process(s); 51 } 52 53 61 public static String prepareTextMinimum(String s) 62 { 63 return minFilter.process(s); 64 } 65 66 72 private static CharacterFilter htmlFilter() 73 { 74 CharacterFilter filter = new CharacterFilter(); 75 filter.addAttribute("\"", Entities.QUOT); 76 filter.addAttribute("'", Entities.LSQUO); 77 filter.addAttribute("&", Entities.AMP); 78 filter.addAttribute("<", Entities.LT); 79 filter.addAttribute(">", Entities.GT); 80 return filter; 81 } 82 83 91 private static CharacterFilter htmlMinFilter() 92 { 93 CharacterFilter filter = new CharacterFilter(); 94 filter.removeAttribute(">"); 95 filter.removeAttribute("\""); 96 filter.removeAttribute("'"); 97 filter.removeAttribute("&"); 98 filter.addAttribute("<", Entities.LT); 99 return filter; 100 } 101 } 102 | Popular Tags |