question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

toolrunner _argStringToArray eats up escaped quotes

See original GitHub issue

Please check our current Issues to see if someone already reported this https://github.com/Microsoft/azure-pipelines-task-lib/issues

Environment

azure-pipelines-task-lib version:

Issue Description

toolrunner _argStringToArray eats up escaped quotes

Expected behavior

It should no remove escaped quotes

Actual behavior

toolrunner _argStringToArray eats up escaped quotes

Steps to reproduce

Server - Azure Pipelines task DotNetCoreCLI@2

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    arguments: '-- TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")'

Other Inputs

  1. If we try passing quotes as a value even that is being eaten up by task-lib Input: -- TestRunParameters.Parameter(name=paramName,value=argwith"aquote) Output -- TestRunParameters.Parameter(name=paramName,value=argwithaquote)
  2. If we use backslash then also quote is eaten up. Input: -- TestRunParameters.Parameter(name=paramName,value=argwith\"aquote) Output -- TestRunParameters.Parameter(name=paramName,value=argwith\aquote)

Other Inputs: Input: -- TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\") Output: TestRunParameters.Parameter(name=\EdiStagingFunctionsKey\",value=\"key2\") Note: Above the first escaped quotes are eaten up.

Input: TestRunParameters.Parameter(name="EdiStagingFunctionsKey",value="key2" Output: TestRunParameters.Parameter(name=EdiStagingFunctionsKey,value=key2)

More details on the issue from customer - https://github.com/microsoft/azure-pipelines-tasks/issues/13130

Our Debug analysis is as below along with the flow: Issue Bug is with azure-task-lib _argStringToArray function - https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/toolrunner.ts#L88

Stack–> https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/toolrunner.ts#L88 https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/toolrunner.ts#L838 https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/DotNetCoreCLIV2/dotnetcore.ts#L170

/cc @nohwnd @ShreyasRmsft @phanikmmsft

Logs

##[debug]C:\Program Files\dotnet\dotnet.exe arg: test
TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")
##[debug]C:\Program Files\dotnet\dotnet.exe arg:  --logger trx --results-directory "C:\agent\_work\_temp" -- TestRunParameters.Parameter(name=\"EdiStagingFunctionsKey\",value=\"key2\")
##[debug]exec tool: C:\Program Files\dotnet\dotnet.exe
##[debug]arguments:
##[debug]   test
##[debug]   --logger
##[debug]   trx
##[debug]   --results-directory
##[debug]   C:\agent\_work\_temp
##[debug]   --
##[debug]   TestRunParameters.Parameter(name=\EdiStagingFunctionsKey",value="key2")
"C:\Program Files\dotnet\dotnet.exe" test --logger trx --results-directory C:\agent\_work\_temp -- "TestRunParameters.Parameter(name=\EdiStagingFunctionsKey\",value=\"key2\")"
##[debug]Exit code 0 received from tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]BuildConfiguration=release
##[debug]BuildPlatform=any cpu

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nohwndcommented, Sep 22, 2020

Yeah, still interested in this being fixed.

1reaction
sudgarrecommented, Mar 2, 2021

Any updates on this issue please ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Escape double quotes in a Jenkins pipeline file's shell command
You need to escape twice, once the quote for the shell with a slash, and once that slash with a slash for groovy...
Read more >
3.3. Quoting characters
Escape characters are used to remove the special meaning from a single character. ... Single quotes ('') are used to preserve the literal...
Read more >
How to escape quotes in shell? - Unix & Linux Stack Exchange
To quote a generic string with double quotes, perform the following actions: Add leading and trailing double quotes: aaa ==> "aaa". Escape with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found