Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
authorDarin Adler <darin@src.gnome.org>
Mon, 27 Aug 2001 18:01:08 +0000 (18:01 +0000)
committerDarin Adler <darin@src.gnome.org>
Mon, 27 Aug 2001 18:01:08 +0000 (18:01 +0000)
* glib/gconvert.h:
* glib/gconvert.c: (g_filename_from_uri):
Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.

* tests/.cvsignore:
* tests/uri-test.c:
Added a lot more test for the new URI functions, including a
number that seem to indicate some minor bugs.

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gconvert.c
glib/gconvert.h
tests/.cvsignore
tests/uri-test.c

index ab29d02..a734770 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index ab29d02..a734770 100644 (file)
@@ -1,3 +1,15 @@
+2001-08-27  Darin Adler  <darin@bentspoon.com>
+
+       * glib/gconvert.h:
+       * glib/gconvert.c: (g_filename_from_uri):
+       Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to
+       G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI.
+       
+       * tests/.cvsignore:
+       * tests/uri-test.c:
+       Added a lot more test for the new URI functions, including a
+       number that seem to indicate some minor bugs.
+
 2001-08-26  Alex Larsson  <alexl@redhat.com>
 
        * glib/gconvert.[ch] (g_filename_from_uri,
index 1246ea4..c280e70 100644 (file)
@@ -1198,8 +1198,8 @@ g_filename_from_uri (const char *uri,
 
   if (!has_case_prefix (uri, "file:/"))
     {
-      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NOT_LOCAL_FILE,
-                  _("The URI `%s' does not specify a local file"),
+      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI,
+                  _("The URI `%s' is not an absolute URI using the file scheme"),
                   uri);
       return NULL;
     }
index 280feda..a6e9d78 100644 (file)
@@ -38,7 +38,7 @@ typedef enum
   G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
   G_CONVERT_ERROR_FAILED,
   G_CONVERT_ERROR_PARTIAL_INPUT,
-  G_CONVERT_ERROR_NOT_LOCAL_FILE,
+  G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI,
   G_CONVERT_ERROR_INVALID_URI,
   G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
 } GConvertError;
index 614a73d..41b92ac 100644 (file)
@@ -46,6 +46,7 @@ testgdateparser
 testglib
 timeloop
 timeloop-basic
+uri-test
 unicode-caseconv
 unicode-collate
 unicode-normalize
index 87b2a62..26a5a67 100644 (file)
@@ -45,9 +45,15 @@ to_uri_tests[] = {
   { "/etc", NULL, "file:///etc"},
   { "/etc", "", "file:///etc"},
   { "/etc", "localhost", "file://localhost/etc"},
+  { "/etc", "otherhost", "file://otherhost/etc"},
 #ifdef G_OS_WIN32
-  { "c:\\windows", NULL, "file:///c:\\windows"},
+  { "c:\\windows", NULL, "file:///c:\\windows"}, /* these 3 tests almost certainly fail */
   { "c:\\windows", "localhost", "file://localhost/c:\\windows"},
+  { "c:\\windows", "otherhost", "file://otherhost/c:\\windows"},
+#else
+  { "c:\\windows", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH}, /* it's important to get this error on Unix */
+  { "c:\\windows", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
+  { "c:\\windows", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
 #endif
   { "etc", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
   { "/etc/öäå", NULL, NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
@@ -55,6 +61,28 @@ to_uri_tests[] = {
   { "/etc", "öäå", "file://%C3%B6%C3%A4%C3%A5/etc"},
   { "/etc", "åäö", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
   { "/etc/file with #%", NULL, "file:///etc/file%20with%20%23%25"},
+  { "", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
+  { "", "", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
+  { "", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
+  { "", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
+  { "/0123456789", NULL, "file:///0123456789"},
+  { "/ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL, "file:///ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
+  { "/abcdefghijklmnopqrstuvwxyz", NULL, "file:///abcdefghijklmnopqrstuvwxyz"},
+  { "/-_.!~*'()", NULL, "file:///-_.!~*'()"},
+  { "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F"},
+  { "/;@+$,", NULL, "file:///%3B%40%2B%24%2C"},
+  { "/:", NULL, "file:///:"}, /* not escaped even though reserved as side effect of DOS support -- is that really what we want on Unix? */
+  { "/?&=", NULL, "file:///?&="}, /* these are not escaped and other reserved characters are -- is that really what we want? */
+  { "/", "0123456789", "file://0123456789/"},
+  { "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/"},
+  { "/", "abcdefghijklmnopqrstuvwxyz", "file://abcdefghijklmnopqrstuvwxyz/"},
+  { "/", "-_.!~*'()", "file://-_.!~*'()/"},
+  { "/", "\"#%<>[\\]^`{|}\x7F", "file://%22%23%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F/"},
+  { "/", ";?&=+$,", "file://%3B%3F%26%3D%2B%24%2C/"},
+  { "/", "/", "file:////"}, /* should be "file://%2F/" or an error */
+  { "/", "@:", "file://@:/"}, /* these are not escaped and other reserved characters are -- is that really what we want? */
+  { "/", "\x80\xFF", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
+  { "/", "\xC3\x80\xC3\xBF", "file://%C3%80%C3%BF/"},
 };
 
 
@@ -68,16 +96,38 @@ typedef struct
 
 FromUriTest
 from_uri_tests[] = {
-  { "file:///etc", "/etc", NULL},
-  { "file:/etc", "/etc", NULL},
-  { "file://localhost/etc", "/etc", "localhost", },
-  { "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost", },
-  { "file://%C3%B6%C3%A4%C3%A5/etc", "/etc", "öäå", },
+  { "file:///etc", "/etc"},
+  { "file:/etc", "/etc"},
+  { "file://localhost/etc", "/etc", "localhost"},
+  { "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost"},
+  { "file://otherhost/etc", "/etc", "otherhost"},
+  { "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"},
+  { "file://%C3%B6%C3%A4%C3%A5/etc", "/etc", "öäå"},
   { "file:////etc/%C3%B6%C3%C3%C3%A5", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
   { "file://localhost/åäö", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
   { "file://åäö/etc", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
   { "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
   { "file://some", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
+  { "", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI}, /* should be G_CONVERT_ERROR_INVALID_URI */
+  { "file:test", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI},
+  { "http://www.yahoo.com/", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI},
+  { "file:////etc", "/etc"}, /* should be "//etc" -- mistake in code for DOS results in dropped slash */
+  { "file://///etc", "//etc"}, /* should be "///etc" -- mistake in code for DOS results in dropped slash */
+  { "file:///c:\\foo", "/c:\\foo"}, /* should be "c:\\foo" on DOS perhaps, but that would be bad for Unix */
+  { "file:///c:/foo", "/c:/foo"}, /* should be "c:/foo" on DOS perhaps, but that would be bad for Unix */
+  { "file:////c:/foo", "/c:/foo"}, /* should be "//c:/foo" on Unix */
+  { "file://0123456789/", "/", "0123456789"},
+  { "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/", "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
+  { "file://abcdefghijklmnopqrstuvwxyz/", "/", "abcdefghijklmnopqrstuvwxyz"},
+  { "file://-_.!~*'()/", "/", "-_.!~*'()"},
+  { "file://\"<>[\\]^`{|}\x7F/", "/", "\"<>[\\]^`{|}\x7F"},
+  { "file://;?&=+$,/", "/", ";?&=+$,"},
+  { "file://%C3%80%C3%BF/", "/", "\xC3\x80\xC3\xBF"},
+  { "file://@/", "/", "@"},
+  { "file://:/", "/", ":"},
+  { "file://#/", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
+  { "file://%23/", "/", "#"}, /* is it dangerous to return a hostname with a "#" character in it? */
+  { "file://%2F/", "/", "/"}, /* is it dangerous to return a hostname with a "/" character in it? */
 };