public static string EscapeForXml(this string input) { return input?.Replace("\"", """); }
public static string Escape(this string s) { return s?.Replace("\\", "\\\\").Replace("'", "\\'"); }
public static string ToHtmlSafeTagText(this string value) { // TODO extend to cover all special chars return value?.Replace("\"", "'"); }
public static string ToHtmlSafeUrl(this string value) { // TODO extend to cover all special chars return value?.Replace(" ", "%20"); }
public static string ToHtmlSafePlainText(this string value) { // TODO extend to cover all special chars, although this is enough for security return value?.Replace("<", "<wbr><").Replace(">", "><wbr>").Replace("=", "<wbr>="); }
internal static string NormalizeForHtml(this string value) => value?.Replace(Environment.NewLine, "<br />") ?? string.Empty;
public static string ToRelativePath(this string absolut) { return absolut?.Replace(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority, ""); }
public static string RemoveNewlines(this string str) { return str?.Replace("\r", "").Replace("\n", ""); }
/// <summary> /// 转换成mysql值 /// </summary> /// <param name="userInput"></param> /// <returns></returns> public static string ToDbValue(this string userInput) { return userInput?.Replace("%", "\\%").Replace("'", "\\'") ?? ""; }