Skip to content

Commit

Permalink
Merge pull request #3661 from iaalm/master
Browse files Browse the repository at this point in the history
Powershell: fix string escape issue
  • Loading branch information
masatake committed Mar 14, 2023
2 parents 457ed6a + bca2e86 commit ac7a805
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Units/parser-powershell.r/simple-powershell.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ ErrorActionPreference input.ps1 /^$ErrorActionPreference = "Stop"$/;" v
Settings input.ps1 /^$Global:Settings = $null$/;" v
ALocalVar input.ps1 /^$Local:ALocalVar = $null$/;" v
BasePath input.ps1 /^$BasePath = split-path -parent $Global:MyInvocation.InvocationName$/;" v
cDrive input.ps1 /^$cDrive="C:\\"$/;" v
nextLine input.ps1 /^$nextLine="`n"$/;" v
backtick input.ps1 /^$backtick='`'$/;" v
Read-Configuration-File input.ps1 /^FUNCTION Read-Configuration-File() {$/;" f signature:()
LogMessageOK input.ps1 /^Function LogMessageOK()$/;" f signature:()
LogMessage input.ps1 /^function LogMessage() {$/;" f signature:()
Expand Down
4 changes: 4 additions & 0 deletions Units/parser-powershell.r/simple-powershell.d/input.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ $Local:ALocalVar = $null
# a usual variable
$BasePath = split-path -parent $Global:MyInvocation.InvocationName

# different type of escape in string
$cDrive="C:\"
$nextLine="`n"
$backtick='`'

FUNCTION Read-Configuration-File() {
$Hostname = [System.Environment]::MachineName
Expand Down
2 changes: 1 addition & 1 deletion parsers/powershell.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static void parseString (vString *const string, const int delimiter)
{
int c = getcFromInputFile ();

if (c == '\\' && (c = getcFromInputFile ()) != EOF)
if (delimiter == '"' && c == '`' && (c = getcFromInputFile ()) != EOF)
vStringPut (string, c);
else if (c == EOF || c == delimiter)
break;
Expand Down

0 comments on commit ac7a805

Please sign in to comment.