Returns the escaped text of a rich text value (reduced HTML escaping).

@param value the rich text value to escape
@return the escaped HTML code of the value
331941
public static String rich(SlingHttpServletRequest request, String value) {
        if (value != null) {
            // ensure that a rich text value is always enclosed with a HTML paragraph tag
            if (StringUtils.isNotBlank(value) && !value.trim().startsWith("<p>")) {
                value = "<p>" + value + "</p>";
            }
            // transform embedded resource links (paths) to mapped URLs
            value = map(request, value);
            value = escapeRichText(value);
        }
        return value;
    }
673538
private static String escapeAttributeValue(String value) {
        final String escapees = ",=+<>#;\"\\";
        char[] chars = value.toCharArray();
        StringBuffer buf = new StringBuffer(2 * value.length());

        // Find leading and trailing whitespace.
        int lead; // index of first char that is not leading whitespace
        for (lead = 0; lead < chars.length; lead++) {
            if (!isWhitespace(chars[lead])) {
                break;
            }
        }
        int trail; // index of last char that is not trailing whitespace
        for (trail = chars.length - 1; trail >= 0; trail--) {
            if (!isWhitespace(chars[trail])) {
                break;
            }
        }

        for (int i = 0; i < chars.length; i++) {
            char c = chars[i];
            if ((i < lead) || (i > trail) || (escapees.indexOf(c) >= 0)) {
                buf.append('\\');
            }
            buf.append(c);
        }
        return new String(buf);
    }
1175416
public ChainWriter encodeXhtml(Object value) throws IOException {
		if(value!=null) {
			if(
				value instanceof Writable
				&& !((Writable)value).isFastToString()
			) {
				// Avoid unnecessary toString calls
				Coercion.write(value, textInXhtmlEncoder, out);
			} else {
				String str = Coercion.toString(value);
				BundleLookupMarkup lookupMarkup;
				BundleLookupThreadContext threadContext = BundleLookupThreadContext.getThreadContext(false);
				if(threadContext!=null) {
					lookupMarkup = threadContext.getLookupMarkup(str);
				} else {
					lookupMarkup = null;
				}
				if(lookupMarkup!=null) lookupMarkup.appendPrefixTo(MarkupType.XHTML, out);
				textInXhtmlEncoder.write(str, out);
				if(lookupMarkup!=null) lookupMarkup.appendSuffixTo(MarkupType.XHTML, out);
			}
		}
		return this;
	}
825002
private static String formatValue(String value)
	{
		if(value == null)
			return "";
		
		value = value.trim();
		
		if(value.startsWith("\"")|| value.startsWith("'"))
			value = value.substring(1);
		
		if(value.endsWith("\"")|| value.endsWith("'"))
			value = value.substring(0, value.length() -1);
		
		return value;
	}
1130881
public static String escapeAttribute (String value)
    {
        for (int ii = 0; ii < ATTR_ESCAPES.length; ++ii) {
            value = value.replace(ATTR_ESCAPES[ii][0], ATTR_ESCAPES[ii][1]);
        }
        return value;
    }
1212964
public static function escape(string $value): string
    {
        if (self::$use_white_list) {
            $preg = '/<(\s*\/?\s*[^(?:'. implode(',', self::$white_list) .')]\s*)>/i';
        } elseif (self::$use_black_list) {
            $preg = '/<(\s*\/?\s*(?:'.  implode(',', self::$black_list) .')\s*)>/i';
        } else {
            $preg = '/<(\s*\/?\s*(?:'. implode(',', self::$default_tags) .')\s*)>/i';
        }

        $value = preg_replace($preg, '&lt;$1&gt;', $value);

        return $value;
    }
182559
public static String quote(final String value) {
        if (value == null) {
            return null;
        }
        String result = value;
        if (!result.startsWith("\"")) {
            result = "\"" + result;
        }
        if (!result.endsWith("\"")) {
            result = result + "\"";
        }
        return result;
    }
977530
public static String toUnderline(String value) {
        StringBuilder result = new StringBuilder();
        if (value != null && value.length() > 0) {
            result.append(value.substring(0, 1).toLowerCase());
            for (int i = 1; i < value.length(); i++) {
                String s = value.substring(i, i + 1);
                if (s.equals(s.toUpperCase())) {
                    result.append("_");
                    result.append(s.toLowerCase());
                } else {
                    result.append(s);
                }
            }
        }
        return result.toString();
    }
962694
public static String escapeJsValue(SoyValue value) {
    // We surround values with spaces so that they can't be interpolated into identifiers
    // by accident.  We could use parentheses but those might be interpreted as a function call.
    if (NullData.INSTANCE == value || value == null) {
      // The JS counterpart of this code in soyutils.js emits " null " for both null and the special
      // JS value undefined.
      return " null ";
    } else if (value instanceof NumberData) {
      // This will emit references to NaN and Infinity.  Client code should not redefine those
      // to store sensitive data.
      return " " + value.numberValue() + " ";
    } else if (value instanceof BooleanData) {
      return " " + value.booleanValue() + " ";
    } else if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.JS)) {
      String jsCode = value.coerceToString();
      // This value may not be embeddable if it contains the substring "</script".
      // TODO(msamuel): Fixup.  We need to be careful because mucking with '<' can
      // break code like
      //    while (i</foo/.exec(str).length)
      // and mucking with / can break
      //    return untrustedHTML.replace(/</g, '&lt;');
      return jsCode;
    } else {
      return escapeJsValue(value.coerceToString());
    }
  }
155756
public static String escapeHtmlRcdata(SoyValue value) {
    value = normalizeNull(value);

    if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
      // We can't allow tags in the output, because that would allow safe HTML containing
      // "<textarea>" to prematurely close the textarea.
      // Instead, we normalize which is semantics preserving in RCDATA.
      return normalizeHtml(value.coerceToString());
    }

    return escapeHtml(value.coerceToString());
  }
672316
private static String processUnicodeEscapes(String value) {
    while (value.contains("\\")) {
      int escapeStart = value.indexOf('\\');
      try {
        if (value.charAt(escapeStart + 1) != 'u') {
          return null;
        }

        String hexDigits;
        int escapeEnd;
        if (value.charAt(escapeStart + 2) != '{') {
          // Simple escape with exactly four hex digits: \\uXXXX
          escapeEnd = escapeStart + 6;
          hexDigits = value.substring(escapeStart + 2, escapeEnd);
        } else {
          // Escape with braces can have any number of hex digits: \\u{XXXXXXX}
          escapeEnd = escapeStart + 3;
          while (Character.digit(value.charAt(escapeEnd), 0x10) >= 0) {
            escapeEnd++;
          }
          if (value.charAt(escapeEnd) != '}') {
            return null;
          }
          hexDigits = value.substring(escapeStart + 3, escapeEnd);
          escapeEnd++;
        }
        // TODO(mattloring): Allow code points greater than the size of a char
        char ch = (char) Integer.parseInt(hexDigits, 0x10);
        if (!isIdentifierPart(ch)) {
          return null;
        }
        value = value.substring(0, escapeStart) + ch + value.substring(escapeEnd);
      } catch (NumberFormatException | StringIndexOutOfBoundsException e) {
        return null;
      }
    }
    return value;
  }
103890
public static String getPrefixFromValue(String value) {
    if (value == null) {
      return null;
    } else if (value.contains(DELIMITER)) {
      String[] list = value.split(DELIMITER);
      if (list != null && list.length > 0) {
        return list[0].replaceAll("\u0000", "");
      } else {
        return null;
      }
    } else {
      return value.replaceAll("\u0000", "");
    }
  }
402366
def prettyhtml(value, autoescape=None):
	''
	value = html_cleaner(value)
	return escape(value) if autoescape\
		and not isinstance(value, SafeData) else mark_safe(value)
1007498
public static String escapeHtml4(String html) {
		Html4Escape escape = new Html4Escape();
		return escape.replace(html).toString();
	}
1217987
def _escape(value):
        
        value = str(value)
        for char, escaped in {' ': '\ ', ',': '\,', '"': '\"'}.items():
            value = value.replace(char, escaped)
        return value
595491
public static String filterHtmlElementName(String value) {
    if (EscapingConventions.FilterHtmlElementName.INSTANCE.getValueFilter().matcher(value).find()) {
      return value;
    }
    logger.log(Level.WARNING, "|filterHtmlElementName received bad value ''{0}''", value);
    return EscapingConventions.FilterHtmlElementName.INSTANCE.getInnocuousOutput();
  }
267933
public static String escapeHtmlAttributeNospace(SoyValue value) {
    value = normalizeNull(value);
    if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
      // |escapeHtmlAttributeNospace should only be used on attribute values that cannot have tags.
      return stripHtmlTags(value.coerceToString(), null, false);
    }
    return escapeHtmlAttributeNospace(value.coerceToString());
  }