示例#1
0
        public override string ReadLine()
        {
            string line = reader.ReadLine();

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

            sb.Length = 0;
            line      = StringFu.StripTags(line, sb);
            line      = StringFu.ConvertSpecialEntities(line);

            return(line);
        }
示例#2
0
        // DEPRECATED! path is always escaped but escaping of fragment is
        // context dependent.
        //static public Uri PathToFileUri (string path, string fragment)
        //

        // Whether fragment should be escaped or not is crucial and depends on the context.
        // Hence the caller of the method should set it accordingly and no default
        // value for escape_fragment is provided.
        static public Uri AddFragment(Uri uri, string fragment, bool dont_escape_fragment)
        {
            if (fragment [0] == '#')
            {
                fragment = fragment.Substring(1);
            }

            if (!dont_escape_fragment)
            {
                fragment = StringFu.HexEscape(fragment);
            }

            fragment = String.Concat(uri.Fragment,
                                     '#',
                                     fragment);              // Append to existing fragment

            return(new Uri(uri, fragment, true /* dont escape*/));
        }
示例#3
0
        // Get a uri of our liking from a user-entered uri
        // Basically hex-escape the path, query and the fragment
        static public Uri UserUritoEscapedUri(string user_uri)
        {
            Uri uri;

            try {
                uri = new Uri(user_uri);
            } catch {
                return(null);
            }

            UriBuilder new_uri = new UriBuilder();

            new_uri.Scheme = uri.Scheme;
            new_uri.Host   = uri.Host;

            if (uri.UserInfo != String.Empty)
            {
                int index = uri.UserInfo.IndexOf(":");
                if (index == -1)
                {
                    new_uri.UserName = uri.UserInfo;
                }
                else
                {
                    new_uri.UserName = uri.UserInfo.Substring(0, index);
                    index++;
                    if (index < uri.UserInfo.Length)
                    {
                        new_uri.Password = uri.UserInfo.Substring(index);
                    }
                }
            }

            if (!uri.IsDefaultPort)
            {
                new_uri.Port = uri.Port;
            }
            new_uri.Path     = StringFu.HexEscape(uri.AbsolutePath);
            new_uri.Query    = uri.Query;          // FIXME: escape ?
            new_uri.Fragment = StringFu.HexEscape(uri.Fragment);

            return(new_uri.Uri);
        }
示例#4
0
 static public string PathToFileUriString(string path)
 {
     return(String.Concat(Uri.UriSchemeFile,
                          Uri.SchemeDelimiter,
                          StringFu.HexEscape(Path.GetFullPath(path))));
 }