Java String Sanitize sanitizeAttribute(String value)

Here you can find the source of sanitizeAttribute(String value)

Description

Nukes special attribute characters.

License

Open Source License

Declaration

public static String sanitizeAttribute(String value) 

Method Source Code

//package com.java2s;
// under the terms of the GNU Lesser General Public License as published

public class Main {
    /** Map of strings that must be replaced inside html attributes and their replacements. (They
     * need to be applied in order so amps are not double escaped.) */
    protected static final String[][] ATTR_ESCAPES = { { "&", "&" }, { "'", "'" }, { "\"", """ },
            { "<", "&lt;" }, { ">", "&gt;" }, };

    /**//from www. j a v a 2  s .co  m
     * Nukes special attribute characters. Ideally this would not be needed, but some integrations
     * do not accept special characters in attributes.
     */
    public static String sanitizeAttribute(String value) {
        for (int ii = 0; ii < ATTR_ESCAPES.length; ++ii) {
            value = value.replace(ATTR_ESCAPES[ii][0], "");
        }
        return value;
    }
}

Related

  1. sanitize(String string, String spaceReplace)
  2. sanitize(String text)
  3. sanitize(String text)
  4. sanitize(String value)
  5. sanitizeAppAlias(String appAlias)
  6. sanitizeBranchName(String currentBranch)
  7. sanitizeBrowserName(String browserName)
  8. sanitizeChatMessage(String message)
  9. sanitizeClassname(String classname)