Skip to content

Bug report: listTitle option with single quote results in error #3357

@milanholemans

Description

@milanholemans

Description

First of all, I do not know if this has been discussed yet or it was intentionally made like this.

The problem occurs with (as far as I checked) all spo commands with a --listTitle option. When you specify a list title that contains a single quote, an error is thrown. For example when I want to retrieve all fields of a list called Parker's Library, I do get following error message.

image

As you can see, there are now 3 single quotes in the getByTitle portion of the URL, this is the reason why the command fails. You can escape the single quote by adding an extra single quote. So when you specify Parker''s Library with 2 single quotes, everything works as expected.

Steps to reproduce

  1. Create a new list with a single quote in the title (e.g. Parker's Library)
  2. Execute any spo command with --listTitle option.
    E.g.
m365 spo field list -u "https://contoso.sharepoint.com" --listTitle "Parker's Library"

Expected results

Command should give the desired output from the list.

Actual results

Invalid expression error.

Diagnostics

No response

CLI for Microsoft 365 version

v5.2.0

nodejs version

16.11.1

Operating system (environment)

Windows

Shell

Windows PowerShell

cli doctor

No response

Additional Info

Do we have to take care of this in our code and replace all single quotes in list titles with 2 single quotes?

const escapedListTitle = args.options.listTitle.replaceAll('\'', '\'\'');

Or should we just add a remark to the docs saying that single quotes should be escaped?

I don't know if there are any other special characters, but I don't think so.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions