Exemplo n.º 1
0
 /// <summary>
 /// Checks if specified url is javascript code or not
 /// </summary>
 public static bool IsJavascriptUrl(string path)
 {
     if (StringCompare.StartsWithMatchCase(ref path, "javascript:"))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if the specified url is virtual
 /// </summary>
 public static bool IsVirtualUrl(string path)
 {
     path = path.ToLower();
     for (int i = 0; i < _NonVirtualUrls.Length; i++)
     {
         // MatchCase test is faster
         if (StringCompare.StartsWithMatchCase(ref path, _NonVirtualUrls[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Removes escaped characters from start and end of phrase
        /// </summary>
        public static string RemoveEscapeQuotesFromTagAttributeValue(string value)
        {
            value = value.Trim();
            if (value.Length > 0)
            {
                // if the text started with escaped characters.
                //if (value.StartsWith("\\'") || value.StartsWith(@"\"""))
                if (StringCompare.StartsWithMatchCase(ref value, "\\'") ||
                    StringCompare.StartsWithMatchCase(ref value, @"\"""))
                {
                    // remove
                    value = value.Remove(0, 2);

                    // End of text will be checked only if begging of it oncludes escaped characters
                    if (value.Length > 0)
                    {
                        // if the text ends with ( \ ) character only,
                        // it seems there is a problem so we will prevent it by adding another ( \ ) at the end of text.
                        if (StringCompare.EndsWithMatchCase(ref value, "\\"))
                        {
                            value = value.Remove(value.Length - 1, 1) + " \\";
                        }
                        else if (StringCompare.EndsWithMatchCase(ref value, "\\'") ||
                                 StringCompare.EndsWithMatchCase(ref value, @"\"""))
                        {
                            value = value.Remove(value.Length - 1, 1);
                        }
                        //if (value.EndsWith("\\"))
                        //    value = value.Remove(value.Length - 1, 1) + " \\";
                        //else if (value.EndsWith("\\'") || value.EndsWith(@"\"""))
                        //    value = value.Remove(value.Length - 1, 1);
                    }
                }
            }
            return(value);
        }