Skip to content

Commit 0cdb19e

Browse files
authored
Fix #175
1 parent 75e579f commit 0cdb19e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

HelpOut.types.ps1xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ $FilePath,
6161
$View = 'PowerShell.Markdown.Help'
6262
)
6363

64-
if ($filePath -match '[\<\>\|\?\*\:]') {
65-
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems."
64+
$illegalCharacters = @('<', '>', '|', '?', '*', ':')
65+
$illegalCharacterRegex = '[' + ($illegalCharacters | Foreach-Object { [regex]::Escape($_) }) + ']'
66+
$illegalCharacterReadable = ($illegalCharacters | Foreach-Object { "`"$_`"" }) -join ', '
67+
68+
$filePathWithoutQualifier = Split-Path $filePath -NoQualifier
69+
if ($filePathWithoutQualifier -match $illegalCharacterRegex) {
70+
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems. It cannot contain any of the characters $illegalCharacterReadable."
6671
return
6772
}
6873

Types/PowerShell.Markdown.Help/Save.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ $FilePath,
2222
$View = 'PowerShell.Markdown.Help'
2323
)
2424

25-
if ($filePath -match '[\<\>\|\?\*\:]') {
26-
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems."
25+
$illegalCharacters = @('<', '>', '|', '?', '*', ':')
26+
$illegalCharacterRegex = '[' + ($illegalCharacters | Foreach-Object { [regex]::Escape($_) }) + ']'
27+
$illegalCharacterReadable = ($illegalCharacters | Foreach-Object { "`"$_`"" }) -join ', '
28+
29+
$filePathWithoutQualifier = Split-Path $filePath -NoQualifier
30+
if ($filePathWithoutQualifier -match $illegalCharacterRegex) {
31+
Write-Warning "Will not .Save to $filePath, because that path will not be readable on all operating systems. It cannot contain any of the characters $illegalCharacterReadable."
2732
return
2833
}
2934

0 commit comments

Comments
 (0)