View | Details | Raw Unified | Return to bug 40901
Collapse All | Expand All

(-)container/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java (-2 / +38 lines)
Lines 1207-1213 Link Here
1207
                  .append("'");
1207
                  .append("'");
1208
1208
1209
                sb.append(">");
1209
                sb.append(">");
1210
                sb.append(trimmed);
1210
                sb.append(encodeHTML(trimmed));
1211
                if (childCacheEntry.context != null)
1211
                if (childCacheEntry.context != null)
1212
                    sb.append("/");
1212
                    sb.append("/");
1213
                sb.append("</entry>");
1213
                sb.append("</entry>");
Lines 1376-1382 Link Here
1376
                if (childCacheEntry.context != null)
1376
                if (childCacheEntry.context != null)
1377
                    sb.append("/");
1377
                    sb.append("/");
1378
                sb.append("\"><tt>");
1378
                sb.append("\"><tt>");
1379
                sb.append(trimmed);
1379
                sb.append(encodeHTML(trimmed));
1380
                if (childCacheEntry.context != null)
1380
                if (childCacheEntry.context != null)
1381
                    sb.append("/");
1381
                    sb.append("/");
1382
                sb.append("</tt></a></td>\r\n");
1382
                sb.append("</tt></a></td>\r\n");
Lines 2183-2190 Link Here
2183
2183
2184
    }
2184
    }
2185
2185
2186
    /**
2187
     * HTML-encode characters in the specified string
2188
     *
2189
     * @param s The string to HTML-encode
2190
     * @return The HTML-encoded string, or null is the
2191
     * specified input string was null.
2192
     */
2193
    protected String encodeHTML(String s) {
2186
2194
2195
        if( null == s) 
2196
            return null;
2187
2197
2198
        char content[] = new char[s.length()];
2199
        s.getChars(0, s.length(), content, 0);
2200
        StringBuffer result = new StringBuffer(content.length + 50);
2201
        for ( int i = 0; i < content.length; i++ ) {
2202
            switch (content[i]) {
2203
                case '<':
2204
                    result.append("&lt;");
2205
                    break;
2206
                case '>':
2207
                    result.append("&gt;");
2208
                    break;
2209
                case '&':
2210
                    result.append("&amp;");
2211
                    break;
2212
                case '"':
2213
                    result.append("&quot;");
2214
                    break;
2215
                default:
2216
                    result.append(content[i]);
2217
            }
2218
        }
2219
        return (result.toString());
2220
2221
     }
2222
2223
2188
    // ------------------------------------------------------ Range Inner Class
2224
    // ------------------------------------------------------ Range Inner Class
2189
2225
2190
2226

Return to bug 40901