View Issue Details

IDProjectCategoryView StatusLast Update
0000585.NET APIApi Changepublic2009-02-05 13:11
ReporterRandy Armstrong Assigned ToRandy Armstrong  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0000585: IPv6 support missing from URL contructor.
Description

/// <summary>
/// Initializes an instance by parsing a URL string.
/// </summary>
public URL(string url)
{
Scheme = UrlScheme.HTTP;
HostName = "localhost";
Port = 0;
Path = null;

        string buffer = url;

        // extract the scheme (default is http).
        int index = buffer.IndexOf(&quot;://&quot;);

        if (index >= 0)
        {
            Scheme = buffer.Substring(0, index);
            buffer = buffer.Substring(index + 3);
        }

        index                   = buffer.IndexOfAny(new char[] {'/'});

        if (index &lt; 0)
        {
            Path = buffer;
            return;
        }

        string hostPortString   = buffer.Substring(0, index);
        IPAddress address;

        try
        {
            address = IPAddress.Parse(hostPortString);
                    }
        catch
        {
            address = null;
        }

        if (address != null && address.AddressFamily == AddressFamily.InterNetworkV6)
        {
            if (hostPortString.Contains(&quot;]&quot;))
            {
                HostName = hostPortString.Substring(0, hostPortString.IndexOf(&quot;]&quot;) + 1);
                if (hostPortString.Substring(hostPortString.IndexOf(']')).Contains(&quot;:&quot;))
                {
                    string portString = hostPortString.Substring(hostPortString.LastIndexOf(':') + 1);
                    if (portString != &quot;&quot;)
                    {
                        try
                        {
                            Port = System.Convert.ToUInt16(portString);
                        }
                        catch
                        {
                            Port = 0;
                        }
                    }
                    else
                    {
                        Port = 0;
                    }
                }
                else
                {
                    Port = 0;
                }

                Path = buffer.Substring(index + 1);
            }
            else
            {
                HostName    = &quot;[&quot; + hostPortString + &quot;]&quot;;
                Port        = 0;
            }

            Path            = buffer.Substring(index + 1);
        }
        else
        {

            // extract the hostname (default is localhost).
            index = buffer.IndexOfAny(new char[] {':', '/'});

            if (index &lt; 0)
            {
                Path = buffer;
                return;
            }

            HostName = buffer.Substring(0, index);

            // extract the port number (default is 0).
            if (buffer[index] == ':')
            {
                buffer = buffer.Substring(index + 1);
                index = buffer.IndexOf(&quot;/&quot;);

                string port = null;

                if (index >= 0)
                {
                    port = buffer.Substring(0, index);
                    buffer = buffer.Substring(index + 1);
                }
                else
                {
                    port = buffer;
                    buffer = &quot;&quot;;
                }

                try
                {
                    Port = (int) System.Convert.ToUInt16(port);
                }
                catch
                {
                    Port = 0;
                }
            }
            else
            {
                buffer = buffer.Substring(index + 1);
            }

            // extract the path.
            Path = buffer;
        }
    }
TagsNo tags attached.

Activities

Randy Armstrong

2009-02-05 13:11

administrator   ~0001113

Fix added to Build 103.0

Issue History

Date Modified Username Field Change
2009-02-05 11:42 Randy Armstrong New Issue
2009-02-05 11:42 Randy Armstrong Status new => assigned
2009-02-05 11:42 Randy Armstrong Assigned To => Randy Armstrong
2009-02-05 13:11 Randy Armstrong Status assigned => resolved
2009-02-05 13:11 Randy Armstrong Resolution open => fixed
2009-02-05 13:11 Randy Armstrong Note Added: 0001113