Fix Import-MamlHelp failing to read <command:uri> in related links#854
Open
teramako wants to merge 2 commits into
Open
Fix Import-MamlHelp failing to read <command:uri> in related links#854teramako wants to merge 2 commits into
<command:uri> in related links#854teramako wants to merge 2 commits into
Conversation
…dLinks Legacy MAML help may be written using `<command:uri>`. PowerShell's built-in MAML reader (Get-Help / Show-HelpPreview) correctly reads `<command:uri>` because it matches only the local-name `uri` and does not require the `maml:` namespace. platyPS should maintain compatibility with this behavior. Older versions of platyPS (prior to 1.0.2) emitted `<command:url>` in Export-MamlCommandHelp, so Import-MamlHelp must support this legacy format to ensure round-trip compatibility. The XmlException occurs because TransformMaml.ReadRelatedLinks calls ReadEndElement() even when the reader is not positioned at an end element. This happens whenever `<maml:uri>` is missing, regardless of PR PowerShell#849. This is a long-standing reader-side bug.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR fixes an issue where Import-MamlHelp fails to read
<command:uri>in<maml:navigationLink>and throws an XmlException.PowerShell’s built-in MAML reader (Get-Help / Show-HelpPreview) correctly reads
<command:uri>because it matches only the local-nameuriand does not require themaml:namespace. platyPS should maintain compatibility with this behavior.Older versions of platyPS (prior to 1.0.2) also emitted
<command:url>in Export-MamlCommandHelp, so Import-MamlHelp must support this legacy format to ensure round‑trip compatibility.This PR updates TransformMaml.ReadRelatedLinks to safely read both
<maml:uri>and<command:uri>usingReadSubtree(), and removes the incorrectReadEndElement()call that caused the XmlException.PR Context
Fixes #852
Summary of changes
<command:uri>in related links (legacy MAML format)ReadSubtree()to safely iterate navigationLink contents<maml:uri>and<command:uri>for compatibility with PowerShell’s MAML readerReadEndElement()call that caused XmlExceptioncommand:uri-in-related-links.xml) and ensure it passes after the fixWhy this change is needed
Import-MamlHelp currently crashes when
<command:uri>is present, even though PowerShell itself reads such MAML files without issue.This breaks compatibility with legacy help content and prevents round‑trip conversion for modules that still use the older format.
This PR restores compatibility and aligns platyPS with PowerShell’s behavior.
This change is