]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uri] Make URI schemes case-insensitive
authorMichael Brown <mcb30@ipxe.org>
Thu, 1 Jul 2021 15:32:46 +0000 (16:32 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 1 Jul 2021 15:32:46 +0000 (16:32 +0100)
RFC 3986 section 3.1 defines URI schemes as case-insensitive (though
the canonical form is always lowercase).

Use strcasecmp() rather than strcmp() to allow for case insensitivity
in URI schemes.

Requested-by: Andreas Hammarskjöld <junior@2PintSoftware.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/open.c
src/net/tcp/httpconn.c

index c27d8a021076128541e6db78ea5affda9230f9b6..f9198c9d90898914e04ec18bbcbf1fb69ddb8568 100644 (file)
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 #include <stdarg.h>
 #include <string.h>
+#include <strings.h>
 #include <errno.h>
 #include <ipxe/xfer.h>
 #include <ipxe/uri.h>
@@ -47,7 +48,7 @@ struct uri_opener * xfer_uri_opener ( const char *scheme ) {
        struct uri_opener *opener;
 
        for_each_table_entry ( opener, URI_OPENERS ) {
-               if ( strcmp ( scheme, opener->scheme ) == 0 )
+               if ( strcasecmp ( scheme, opener->scheme ) == 0 )
                        return opener;
        }
        return NULL;
index f9221b27eb7311273a911108958dc2eb73750395..538c4dcf6e5a94788f012a32f41532a9dd4d5b88 100644 (file)
@@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <errno.h>
 #include <byteswap.h>
 #include <ipxe/tcpip.h>
@@ -63,7 +64,7 @@ static struct http_scheme * http_scheme ( struct uri *uri ) {
 
        /* Identify scheme */
        for_each_table_entry ( scheme, HTTP_SCHEMES ) {
-               if ( strcmp ( uri->scheme, scheme->name ) == 0 )
+               if ( strcasecmp ( uri->scheme, scheme->name ) == 0 )
                        return scheme;
        }