private String parseQuoted()

in src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Parser.java [258:298]


    private String parseQuoted(String tx) {
        StringBuffer buf = new StringBuffer();
        int size = tx.length();
        int i = 0;
        while (i < size) {
            char ch = tx.charAt(i);
            if (ch == '&') {
                if (i + 5 < size && tx.charAt(i + 1) == 'a'
                        && tx.charAt(i + 2) == 'p' && tx.charAt(i + 3) == 'o'
                        && tx.charAt(i + 4) == 's' && tx.charAt(i + 5) == ';') {
                    buf.append('\'');
                    i += 6;
                } else if (i + 5 < size && tx.charAt(i + 1) == 'q'
                        && tx.charAt(i + 2) == 'u' && tx.charAt(i + 3) == 'o'
                        && tx.charAt(i + 4) == 't' && tx.charAt(i + 5) == ';') {
                    buf.append('"');
                    i += 6;
                } else {
                    buf.append(ch);
                    ++i;
                }
            } else if (ch == '\\' && i + 1 < size) {
                ch = tx.charAt(i + 1);
                if (ch == '\\' || ch == '\"' || ch == '\'' || ch == '>') {
                    buf.append(ch);
                    i += 2;
                } else if (ch == '$') {
                    // Replace "\$" with some special char. XXX hack!
                    buf.append(Constants.ESC);
                    i += 2;
                } else {
                    buf.append('\\');
                    ++i;
                }
            } else {
                buf.append(ch);
                ++i;
            }
        }
        return buf.toString();
    }