Escapes the text passed in so that it is treated as data instead of
control characters.

@param text data to be escaped
@return the escaped text.
768968
public static String escapeLuceneQuery(final CharSequence text) {
        if (text == null) {
            return null;
        }
        final int size = text.length() << 1;
        final StringBuilder buf = new StringBuilder(size);
        appendEscapedLuceneQuery(buf, text);
        return buf.toString();
    }
628943
protected String escapeApostrophes(String text) {
		String resultString;
		if (text.contains("'")) {
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.append("concat('");
			stringBuilder.append(text.replace("'", "',\"'\",'"));
			stringBuilder.append("')");
			resultString = stringBuilder.toString();
		} else {
			resultString = "'" + text + "'";
		}
		return resultString;
	}
704035
private String escapeCodeText(String text) {
    String lowerText = text.toLowerCase();
    int preStart = lowerText.indexOf("<pre>");
    int preEnd = lowerText.indexOf("</pre>");
    if (preStart == -1 && preEnd == -1) {
      return text;
    }
    if (preStart >= 0 && preEnd >= 0 && preEnd < preStart) {
      // Bad code formatting, don't try to escape.
      return text;
    }

    // Separately test begin and end tags, to support a span with multiple Javadoc tags.
    StringBuilder sb = new StringBuilder();
    if (preStart > -1 && preEnd > -1) {
      // Both <pre> and </pre> are in the same text segment.
      sb.append(text.substring(0, preStart));
      if (preStart > 0) {
        sb.append('\n');
      }
      sb.append("@code\n");
      sb.append(text.substring(preStart + "<pre>".length(), preEnd));
      sb.append("\n@endcode");
      sb.append(text.substring(preEnd + "</pre>".length()));
    } else if (preStart > -1) {
      // The text has <pre> but not the </pre> should be in a following Javadoc tag.
      sb.append(text.substring(0, preStart));
      if (preStart > 0) {
        sb.append('\n');
      }
      sb.append("@code\n");
      sb.append(text.substring(preStart + "<pre>".length()));
      spanningPreTag = true;
    } else {
      // The text just has a </pre>.
      sb.append("\n@endcode");
      sb.append(text.substring(preEnd + "</pre>".length()));
      spanningPreTag = false;
    }
    return escapeCodeText(sb.toString());  // Allow for multiple <pre> spans in single text element.
  }
669022
public String decode(String text) {
    if (text == null) { return null; }
    if ((!text.startsWith(Prefix)) || (!text.endsWith(Postfix)))
      throw new IllegalArgumentException("RFC 1522 violation: malformed encoded content");
    int terminator = text.length() - 2;
    int from = 2;
    int to = text.indexOf(Sep, from);
    if (to == terminator) throw new IllegalArgumentException("RFC 1522 violation: charset token not found");
    String charset = text.substring(from, to);
    if (charset.equals("")) throw new IllegalArgumentException("RFC 1522 violation: charset not specified");
    from = to + 1;
    to = text.indexOf(Sep, from);
    if (to == terminator) throw new IllegalArgumentException("RFC 1522 violation: encoding token not found");
    String encoding = text.substring(from, to);
    if (!getEncoding().equalsIgnoreCase(encoding))
      throw new IllegalArgumentException("This codec cannot decode " + encoding + " encoded content");
    from = to + 1;
    to = text.indexOf(Sep, from);
    return new String(Base64.decode(text.substring(from, to).toCharArray()), Charset.forName(charset));
  }
607667
public static String makeLinear (String text)
    {
        if (text == null) {
            return text;
        }
        // handle both line ending formats
        text = text.replace("\n", "<br>\n");
        return text;
    }
233050
public static String untaint (String text)
    {
        return isTainted(text) ? text.substring(TAINT_CHAR.length()) : text;
    }
1026992
public String endsWith(final CharSequence text) {
		if (dialect == null) {
			throw new IllegalStateException("dialect is not set.");
		}
		if (StringUtils.isEmpty(text)) {
			return "%";
		} else {
			return "%" + dialect.escapeLikePattern(text);
		}
	}
600238
public static function escape($text)
    {
        $tagregexp = implode('|', array_map('preg_quote', static::_list()));
        preg_match_all('/(.?){(' . $tagregexp . ')\b(.*?)(?:(\/))?}(?:(.+?){\/\2})?(.?)/s', $text, $matches);

        foreach ($matches[0] as $ht) {
            $replace = str_replace_once('{', '{{', $ht);
            $replace = str_replace_last('}', '}}', $replace);
            $text = str_replace($ht, $replace, $text);
        }

        return $text;
    }
992019
protected String escape(String s) {
		if(s == null)
			return null;
        StringBuilder sb = new StringBuilder();
        escape(s, sb);
        return sb.toString();
    }
474653
static String escape(final String text, final UriEscapeType escapeType, final String encoding) {

        if (text == null) {
            return null;
        }

        StringBuilder strBuilder = null;

        final int offset = 0;
        final int max = text.length();

        int readOffset = offset;

        for (int i = offset; i < max; i++) {

            final int codepoint = Character.codePointAt(text, i);

            /*
             * Shortcut: most characters will be alphabetic, and we won't need to do anything at
             * all for them. No need to use the complete UriEscapeType check system at all.
             */
            if (UriEscapeType.isAlpha(codepoint)) {
                continue;
            }

            /*
             * Check whether the character is allowed or not
             */
            if (escapeType.isAllowed(codepoint)) {
                continue;
            }


            /*
             * At this point we know for sure we will need some kind of escape, so we
             * can increase the offset and initialize the string builder if needed, along with
             * copying to it all the contents pending up to this point.
             */

            if (strBuilder == null) {
                strBuilder = new StringBuilder(max + 20);
            }

            if (i - readOffset > 0) {
                strBuilder.append(text, readOffset, i);
            }

            if (Character.charCount(codepoint) > 1) {
                // This is to compensate that we are actually reading two char[] positions with a single codepoint.
                i++;
            }

            readOffset = i + 1;


            /*
             * -----------------------------------------------------------------------------------------
             *
             * Perform the real escape
             *
             * -----------------------------------------------------------------------------------------
             */

            final byte[] charAsBytes;
            try {
                charAsBytes = new String(Character.toChars(codepoint)).getBytes(encoding);
            } catch (final UnsupportedEncodingException e) {
                throw new IllegalArgumentException("Exception while escaping URI: Bad encoding '" + encoding + "'", e);
            }
            for (final byte b : charAsBytes) {
                strBuilder.append('%');
                strBuilder.append(printHexa(b));
            }


        }


        /*
         * -----------------------------------------------------------------------------------------------
         * Final cleaning: return the original String object if no escape was actually needed. Otherwise
         *                 append the remaining unescaped text to the string builder and return.
         * -----------------------------------------------------------------------------------------------
         */

        if (strBuilder == null) {
            return text;
        }

        if (max - readOffset > 0) {
            strBuilder.append(text, readOffset, max);
        }

        return strBuilder.toString();

    }
206381
public static String escape(CharSequence content) {
		if (StrUtil.isBlank(content)) {
			return StrUtil.str(content);
		}

		final StringBuilder builder = new StringBuilder();
		int len = content.length();
		char current;
		for (int i = 0; i < len; i++) {
			current = content.charAt(i);
			if (RE_KEYS.contains(current)) {
				builder.append('\\');
			}
			builder.append(current);
		}
		return builder.toString();
	}
1170255
private String escapeText(StringBuilder sb, String text)
   {
      int length = text.length();
      char c;

      sb.setLength(0);

      for (int loop = 0; loop < length; loop++)
      {
         c = text.charAt(loop);

         switch (c)
         {
            case '<':
            {
               sb.append("&lt;");
               break;
            }

            case '>':
            {
               sb.append("&gt;");
               break;
            }

            case '&':
            {
               sb.append("&amp;");
               break;
            }

            default:
            {
               if (validXMLCharacter(c))
               {
                  if (c > 127)
                  {
                     sb.append("&#" + (int) c + ";");
                  }
                  else
                  {
                     sb.append(c);
                  }
               }

               break;
            }
         }
      }

      return (sb.toString());
   }
1133188
public static String urlquote(String text) {
        try {
            return URLEncoder.encode(text, "UTF-8").replace("+", "%20");
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        }
    }
252621
protected String encodeCEFExtension(String text) {
		String encoded = text;
		
		// back-slash encode back-slashes (needs to be first)
		encoded = encoded.replace("\\","\\\\");
		
		// back-slash encode equals signs
		encoded = encoded.replace("=","\\=");
		
		// strip carriage returns and newlines
		encoded = encoded.replace("\r", "");
		encoded = encoded.replace("\n", "");
		
		return encoded;
	}
370138
public String encryptText(String text)
	throws Exception
	{
		return toByteText(this.encrypt(text.getBytes(IO.CHARSET)));

	}
896346
private static String decode(final String text)
        throws UnsupportedEncodingException {
        try {
            return URLDecoder.decode(text, Charset.defaultCharset().name());
        } catch (final IllegalArgumentException ex) {
            throw new DecodingException(ex);
        }
    }
489774
public static String escapeDoubleQuotesForJson(String text) {
		if ( text == null ) {
			return null;
		}
		StringBuilder builder = new StringBuilder( text.length() );
		for ( int i = 0; i < text.length(); i++ ) {
			char c = text.charAt( i );
			switch ( c ) {
				case '"':
				case '\\':
					builder.append( "\\" );
				default:
					builder.append( c );
			}
		}
		return builder.toString();
	}