Skip to content
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

Powershell: fix string escape issue #3661

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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