-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[X] Protect some xmlns #28909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[X] Protect some xmlns #28909
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -336,16 +336,25 @@ static IValueNode GetValueNode(object value, XmlReader reader) | |||||
static void GatherXmlnsDefinitionAttributes() | ||||||
{ | ||||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); | ||||||
s_xmlnsDefinitions = new List<XmlnsDefinitionAttribute>(); | ||||||
s_xmlnsDefinitions = []; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using [] to initialize s_xmlnsDefinitions is not valid in C#. Please replace it with a proper List initialization, e.g., 'new List();'.
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try the latest c# Mr AI |
||||||
|
||||||
foreach (var assembly in assemblies) | ||||||
{ | ||||||
try | ||||||
{ | ||||||
foreach (XmlnsDefinitionAttribute attribute in assembly.GetCustomAttributes(typeof(XmlnsDefinitionAttribute))) | ||||||
{ | ||||||
attribute.AssemblyName ??= assembly.FullName; | ||||||
//maui, and x: xmlns are protected | ||||||
if (attribute.XmlNamespace.StartsWith("http://schemas.microsoft.com/", StringComparison.Ordinal) && | ||||||
!attribute.AssemblyName.StartsWith("Microsoft", StringComparison.Ordinal) && | ||||||
!attribute.AssemblyName.StartsWith("System", StringComparison.Ordinal) && | ||||||
!attribute.AssemblyName.StartsWith("mscorlib", StringComparison.Ordinal)) | ||||||
{ | ||||||
Debug.WriteLine($"Can not overloadxmlns {attribute.XmlNamespace}. cause it's protected."); | ||||||
continue; | ||||||
} | ||||||
s_xmlnsDefinitions.Add(attribute); | ||||||
attribute.AssemblyName = attribute.AssemblyName ?? assembly.FullName; | ||||||
} | ||||||
} | ||||||
catch (Exception ex) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would using
https://
instead ofhttp://
allow me to bypass this check?I'm not exactly sure if this is supposed to be a hard check or a soft check.