~ubuntu-branches/ubuntu/precise/tomcat7/precise-proposed

« back to all changes in this revision

Viewing changes to java/org/apache/jasper/compiler/JspUtil.java

  • Committer: Bazaar Package Importer
  • Author(s): tony mancill
  • Date: 2011-07-25 22:58:33 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110725225833-1t773ak3y3g9utm2
Tags: 7.0.19-1
* Team upload.
* New upstream release.
  - Includes fix for CVE-2011-2526 (Closes: #634992)
* Remove patch for CVE-2011-2204 (included upstream).

Show diffs side-by-side

added added

removed removed

Lines of Context:
804
804
     * @return Legal Java identifier corresponding to the given identifier
805
805
     */
806
806
    public static final String makeJavaIdentifier(String identifier) {
 
807
        return makeJavaIdentifier(identifier, true);
 
808
    }
 
809
 
 
810
    /**
 
811
     * Converts the given identifier to a legal Java identifier
 
812
     * to be used for JSP Tag file attribute names. 
 
813
     * 
 
814
     * @param identifier
 
815
     *            Identifier to convert
 
816
     * 
 
817
     * @return Legal Java identifier corresponding to the given identifier
 
818
     */
 
819
    public static final String makeJavaIdentifierForAttribute(String identifier) {
 
820
        return makeJavaIdentifier(identifier, false);
 
821
    }
 
822
 
 
823
    /**
 
824
     * Converts the given identifier to a legal Java identifier.
 
825
     * 
 
826
     * @param identifier
 
827
     *            Identifier to convert
 
828
     * 
 
829
     * @return Legal Java identifier corresponding to the given identifier
 
830
     */
 
831
    private static final String makeJavaIdentifier(String identifier,
 
832
            boolean periodToUnderscore) {
807
833
        StringBuilder modifiedIdentifier = new StringBuilder(identifier.length());
808
834
        if (!Character.isJavaIdentifierStart(identifier.charAt(0))) {
809
835
            modifiedIdentifier.append('_');
810
836
        }
811
837
        for (int i = 0; i < identifier.length(); i++) {
812
838
            char ch = identifier.charAt(i);
813
 
            if (Character.isJavaIdentifierPart(ch) && ch != '_') {
 
839
            if (Character.isJavaIdentifierPart(ch) &&
 
840
                    (ch != '_' || !periodToUnderscore)) {
814
841
                modifiedIdentifier.append(ch);
815
 
            } else if (ch == '.') {
 
842
            } else if (ch == '.' && periodToUnderscore) {
816
843
                modifiedIdentifier.append('_');
817
844
            } else {
818
845
                modifiedIdentifier.append(mangleChar(ch));