From ee2712c487b180b4b28830d6582135d35e6bbe1a Mon Sep 17 00:00:00 2001 From: Darin Adler Date: Mon, 27 Aug 2001 18:01:08 +0000 Subject: [PATCH] Updated name of error from G_CONVERT_ERROR_NOT_LOCAL_FILE to * 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. --- ChangeLog | 12 +++++++++++ ChangeLog.pre-2-0 | 12 +++++++++++ ChangeLog.pre-2-10 | 12 +++++++++++ ChangeLog.pre-2-12 | 12 +++++++++++ ChangeLog.pre-2-2 | 12 +++++++++++ ChangeLog.pre-2-4 | 12 +++++++++++ ChangeLog.pre-2-6 | 12 +++++++++++ ChangeLog.pre-2-8 | 12 +++++++++++ glib/gconvert.c | 4 ++-- glib/gconvert.h | 2 +- tests/.cvsignore | 1 + tests/uri-test.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------ 12 files changed, 156 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab29d02..a734770 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ab29d02..a734770 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +2001-08-27 Darin Adler + + * 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 * glib/gconvert.[ch] (g_filename_from_uri, diff --git a/glib/gconvert.c b/glib/gconvert.c index 1246ea4..c280e70 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -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; } diff --git a/glib/gconvert.h b/glib/gconvert.h index 280feda..a6e9d78 100644 --- a/glib/gconvert.h +++ b/glib/gconvert.h @@ -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; diff --git a/tests/.cvsignore b/tests/.cvsignore index 614a73d..41b92ac 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore @@ -46,6 +46,7 @@ testgdateparser testglib timeloop timeloop-basic +uri-test unicode-caseconv unicode-collate unicode-normalize diff --git a/tests/uri-test.c b/tests/uri-test.c index 87b2a62..26a5a67 100644 --- a/tests/uri-test.c +++ b/tests/uri-test.c @@ -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? */ }; -- 2.7.4