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.

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
- Create a new list with a single quote in the title (e.g.
Parker's Library)
- 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.
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
--listTitleoption. 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 calledParker's Library, I do get following error message.As you can see, there are now 3 single quotes in the
getByTitleportion 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 specifyParker''s Librarywith 2 single quotes, everything works as expected.Steps to reproduce
Parker's Library)--listTitleoption.E.g.
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?
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.