]> git.saurik.com Git - wxWidgets.git/commitdiff
more standard (although less RFC-conformant) treatment of file: URIs (patch 1415189)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 9 Feb 2006 03:09:36 +0000 (03:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 9 Feb 2006 03:09:36 +0000 (03:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37403 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/uri.tex
src/common/uri.cpp
tests/uris/uris.cpp

index f0a63fca327225c39f78c8ef6ad2708e531a5338..60f5e8699442ee45eff49aabee9872f4a1e8a15e 100644 (file)
@@ -75,6 +75,12 @@ if(myuri.HasScheme())
    protocol = myuri.GetScheme();
 \end{verbatim}
 
+\membersection{Deviations from the RFC}\label{deviationsfromrfc}
+
+Note that on URIs with a "file" scheme wxURI does not
+parse the userinfo, server, or port portion.  This is to keep 
+compatability with wxFileSystem, the old wxURL, and older url specifications.
+
 \membersection{wxURI::wxURI}\label{wxuriwxuri}
 
 \func{}{wxURI}{\void}
index c195d13729c3d93ea5b632d62f76f0b3b56adbf4..ccc0149a4b33e20eb297aaaff2c6401a8667eb9b 100644 (file)
@@ -432,11 +432,18 @@ const wxChar* wxURI::ParseAuthority(const wxChar* uri)
     // authority     = [ userinfo "@" ] host [ ":" port ]
     if (*uri == wxT('/') && *(uri+1) == wxT('/'))
     {
+        //skip past the two slashes
         uri += 2;
 
+        // ############# DEVIATION FROM RFC #########################
+        // Don't parse the server component for file URIs
+        if(m_scheme != wxT("file"))
+        {
+            //normal way
         uri = ParseUserInfo(uri);
         uri = ParseServer(uri);
         return ParsePort(uri);
+        }
     }
 
     return uri;
index ec59baf1edb6d5a1f2ddec14f4e2aa9567155a77..1d05f04541f2563b69c925cb692ef32a47f77e85 100644 (file)
@@ -49,6 +49,7 @@ private:
         CPPUNIT_TEST( Assignment );
         CPPUNIT_TEST( Comparison );
         CPPUNIT_TEST( Unescaping );
+        CPPUNIT_TEST( FileScheme );
 #if TEST_URL
         CPPUNIT_TEST( URLCompat );
 #if wxUSE_PROTOCOL_HTTP
@@ -68,6 +69,7 @@ private:
     void Assignment();
     void Comparison();
     void Unescaping();
+    void FileScheme();
 
 #if TEST_URL
     void URLCompat();
@@ -299,6 +301,26 @@ void URITestCase::Unescaping()
     CPPUNIT_ASSERT(works2.IsSameAs(broken2));
 
 }
+
+void URITestCase::FileScheme()
+{
+    //file:// variety (NOT CONFORMANT TO THE RFC)
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file://e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("e:/wxcode/script1.xml") );
+
+    //file:/// variety
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file:///e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("/e:/wxcode/script1.xml") );
+
+    //file:/ variety
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file:/e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("/e:/wxcode/script1.xml") );
+
+    //file: variety
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file:e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("e:/wxcode/script1.xml") );
+}
+
 #if TEST_URL
 
 const wxChar* pszProblemUrls[] = { wxT("http://www.csdn.net"),