Skip to content

Commit

Permalink
Escape type namespaces, document that we aren't escaping names for now
Browse files Browse the repository at this point in the history
  • Loading branch information
CoffeeFlux authored and lewing committed Oct 7, 2019
1 parent 8760cd4 commit d12db16
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mono/metadata/icall.c
Expand Up @@ -3099,16 +3099,19 @@ ves_icall_RuntimeType_get_Name (MonoReflectionTypeHandle reftype, MonoError *err
MonoDomain *domain = mono_domain_get ();
MonoType *type = MONO_HANDLE_RAW(reftype)->type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
// FIXME: this should be escaped in some scenarios with mono_identifier_escape_type_name_chars
// Determining exactly when to do so is fairly difficult, so for now we don't bother to avoid regressions
const char *klass_name = m_class_get_name (klass);

if (type->byref) {
char *n = g_strdup_printf ("%s&", m_class_get_name (klass));
char *n = g_strdup_printf ("%s&", klass_name);
MonoStringHandle res = mono_string_new_handle (domain, n, error);

g_free (n);

return res;
} else {
return mono_string_new_handle (domain, m_class_get_name (klass), error);
return mono_string_new_handle (domain, klass_name, error);
}
}

Expand All @@ -3124,8 +3127,11 @@ ves_icall_RuntimeType_get_Namespace (MonoReflectionTypeHandle type, MonoError *e

if (m_class_get_name_space (klass) [0] == '\0')
return NULL_HANDLE_STRING;
else
return mono_string_new_handle (domain, m_class_get_name_space (klass), error);

char *escaped = mono_identifier_escape_type_name_chars (m_class_get_name_space (klass));
MonoStringHandle res = mono_string_new_handle (domain, escaped, error);
g_free (escaped);
return res;
}

gint32
Expand Down

0 comments on commit d12db16

Please sign in to comment.