Example #1
0
 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>&lt;").Replace(">", "><wbr>").Replace("=", "<wbr>=");
 }
Example #6
0
 internal static string NormalizeForHtml(this string value)
     => value?.Replace(Environment.NewLine, "<br />") ?? string.Empty;        
Example #7
0
 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", "");
 }
Example #9
0
 /// <summary>
 /// 转换成mysql值
 /// </summary>
 /// <param name="userInput"></param>
 /// <returns></returns>
 public static string ToDbValue(this string userInput)
 {
     return userInput?.Replace("%", "\\%").Replace("'", "\\'") ?? "";
 }