Unescape a string. @param s the string to unescape @return the unescaped string
(String s)
| 2862 | * @return the unescaped string |
| 2863 | */ |
| 2864 | protected String unescape(String s) { |
| 2865 | if (s == null) { |
| 2866 | return null; |
| 2867 | } |
| 2868 | if (s.indexOf('\\') == -1) { |
| 2869 | return s; |
| 2870 | } |
| 2871 | StringBuilder buf = new StringBuilder(); |
| 2872 | for (int i = 0; i < s.length(); i++) { |
| 2873 | char c = s.charAt(i); |
| 2874 | if (c != '\\') { |
| 2875 | buf.append(c); |
| 2876 | } else { |
| 2877 | if (++i >= s.length()) { |
| 2878 | throw new IllegalArgumentException();// invalid escape, hence invalid cookie |
| 2879 | } |
| 2880 | c = s.charAt(i); |
| 2881 | buf.append(c); |
| 2882 | } |
| 2883 | } |
| 2884 | return buf.toString(); |
| 2885 | } |
| 2886 | |
| 2887 | private CookieProcessor getCookieProcessor() { |
| 2888 | Context context = getContext(); |