Skip to content

Script arguments to debug adapter should be wrapped in quotes if they contain spaces #190

Open

Description

@daviwil

See the following two issues for more information.

microsoft/vscode#4057
PowerShell/vscode-powershell#117

Activity

  1. added this to the 0.6.0 milestone on Mar 15, 2016
  2. rkeithhill commented on Mar 25, 2016

    @rkeithhill
    Contributor

    We have to be careful/smart about this. If you wrap "-Index", "1, 2, 3" with quotes you get -Index "1, 2, 3" and now we've changed the type of the argument from [int[]] to [string]. You could say that folks should do this instead "-Index", "1", "2", "3" or "-Index 1, 2, 3". The first will work but the second will totally break because SomeCommand "-Index 1, 2, 3" is a lot different than SomeCommand -Index 1, 2, 3.

    I dunno on this one. Seems like it would be a bit dangerous to do this.

    Another solution would be to only support a single string and not an array of strings for args. Then it should make it more obvious that individual arguments with spaces need internal quoting e.g. "-Index 1, 2, 3 -Path 'C:\program files'". The downside is that this would be a breaking change.

  3. daviwil commented on Mar 25, 2016

    @daviwil
    ContributorAuthor

    Yeah, you're right, maybe we should just be accepting a single string. There's not really a good reason to accept an array of strings since it complicates everything.

    Maybe we can just change our schema in VS Code for now to specify string for the args field so that the user gets a warning if they're using an array. In our LaunchRequest we can change the Args property to be JToken so that either a string or an array can be passed. We'd have to do an extra step to determine if Args contains a JValue or a JArray and then act accordingly.

  4. daviwil commented on Mar 25, 2016

    @daviwil
    ContributorAuthor

    Forgot to should add, we'd deprecate the array support after a version or two once we have appropriate documentation showing how to do args the right way. At the time of deprecation we could even give a specific error message from the debug adapter warning the user of this.

  5. rkeithhill commented on Mar 25, 2016

    @rkeithhill
    Contributor

    Another somewhat lame option if we were to keep array of strings is to add more help in the scheme e.g.:

    vscodeargswithspacetip

    The problem with this is that it isn't very likely users would hover over the args field to get this tip. Meh, probably better to change to using just a single string.

    My original thinking with array of args was that we would eventually crack the nut on AddCommand instead of AddScript (to avoid the script injection issue Lee talked about) then we would need the array of args. I'm not sure that will ever happen at this point.

  6. daviwil commented on Mar 25, 2016

    @daviwil
    ContributorAuthor

    Yeah... I thought about that too. Though I think it's considered "more secure" to use AddCommand so I'd like to do it at some point. We may still be able to accomplish this with a single string by using PowerShell's parser to get an AST for the string to use for passing to AddParameter/AddArgument.

  7. modified the milestones: 0.7.0, on Sep 2, 2016
  8. removed this from the milestone on Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions