[netcore] Make assembly name parsing and comparison case-insensitive (mono/mono#15522)
authorRyan Lucia <rylucia@microsoft.com>
Mon, 22 Jul 2019 15:23:26 +0000 (11:23 -0400)
committerMarek Safar <marek.safar@gmail.com>
Mon, 22 Jul 2019 15:23:26 +0000 (17:23 +0200)
* Re-enable test

* Parse assembly info case-insensitively

* Lowercase the parsed public key token

* Case-insensitive comparison of public key tokens

* Fix string copy

Commit migrated from https://github.com/mono/mono/commit/beb5553398480fee3543a526fff52633dbde12b1

src/mono/mono/metadata/assembly.c
src/mono/mono/metadata/reflection.c
src/mono/netcore/CoreFX.issues.rsp

index ac1aa3e..16c7815 100644 (file)
@@ -428,7 +428,7 @@ encode_public_tok (const guchar *token, gint32 len)
 gboolean
 mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *pubt2)
 {
-       return memcmp (pubt1, pubt2, 16) == 0;
+       return g_ascii_strncasecmp ((const char*) pubt1, (const char*) pubt2, 16) == 0;
 }
 
 /**
index 1763871..3ec2151 100644 (file)
@@ -1521,7 +1521,7 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) {
        while (g_ascii_isspace (*p))
                p++;
        while (*p) {
-               if (*p == 'V' && g_ascii_strncasecmp (p, "Version=", 8) == 0) {
+               if ((*p == 'V' || *p == 'v') && g_ascii_strncasecmp (p, "Version=", 8) == 0) {
                        p += 8;
                        assembly->major = strtoul (p, &s, 10);
                        if (s == p || *s != '.')
@@ -1539,7 +1539,7 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) {
                        if (s == p)
                                return 1;
                        p = s;
-               } else if (*p == 'C' && g_ascii_strncasecmp (p, "Culture=", 8) == 0) {
+               } else if ((*p == 'C' || *p == 'c') && g_ascii_strncasecmp (p, "Culture=", 8) == 0) {
                        p += 8;
                        if (g_ascii_strncasecmp (p, "neutral", 7) == 0) {
                                assembly->culture = "";
@@ -1550,7 +1550,7 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) {
                                        p++;
                                }
                        }
-               } else if (*p == 'P' && g_ascii_strncasecmp (p, "PublicKeyToken=", 15) == 0) {
+               } else if ((*p == 'P' || *p == 'p') && g_ascii_strncasecmp (p, "PublicKeyToken=", 15) == 0) {
                        p += 15;
                        if (strncmp (p, "null", 4) == 0) {
                                p += 4;
@@ -1563,7 +1563,9 @@ assembly_name_to_aname (MonoAssemblyName *assembly, char *p) {
                                len = (p - start + 1);
                                if (len > MONO_PUBLIC_KEY_TOKEN_LENGTH)
                                        len = MONO_PUBLIC_KEY_TOKEN_LENGTH;
-                               g_strlcpy ((char*)assembly->public_key_token, start, len);
+                               char* pkt_lower = g_ascii_strdown (start, len);
+                               g_strlcpy ((char*) assembly->public_key_token, pkt_lower, len);
+                               g_free (pkt_lower);
                        }
                } else {
                        while (*p && *p != ',')
index 781bb2c..414f6ed 100644 (file)
 # https://github.com/mono/mono/issues/15076
 -nomethod System.Reflection.Tests.AssemblyTests.LoadFrom_SameIdentityAsAssemblyWithDifferentPath_ReturnsEqualAssemblies
 
-# throws a NRE
-# https://github.com/mono/mono/issues/15077
--nomethod System.Reflection.Tests.GetTypeTests.GetType
 
 # Assertion expects false, but we return true
 # https://github.com/mono/mono/issues/15080