Skip to content

[BUG] ListItemComments control: Error when using some special characters in text #2047

@zapftho

Description

@zapftho

Category

[ ] Enhancement

[X] Bug

[ ] Question

Version

Please specify what version of the library you are using:
3.22.0

Expected / Desired Behavior / Question

Adding some comments should be possible also when including some specific special characters such as \ or double quotes ("). This does work for the SharePoint Standard comments control so it is expected to work with the PnP Control as well.

Observed Behavior

When adding a text containing some special characters such as "This is a test \ repro" adding the comment will fail with the ListItemComments control. An error is shown in developer tools:

{
    "error": {
        "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
        "message": "Invalid JSON. An unrecognized escape sequence '\\ ' was found in a JSON string value."
    }
}

This is what the payload looks like:

Image

When compared to SharePoint Standard implementation I can see that in SharePoint Standard comments component is encoding special characters before its submitted to the Comments API:

Image

So I guess the issue could be addressed by doing the same thing here in the PnP Component. I noticed it is working fine for most other special characters (&,%,$,§,!,/,{,[,],},?.=) but for the SharePoint Standard component it seems its always encoding all the special characters so it might be more safe to do the same in the PnP Component as well.

Steps to Reproduce

  1. Add the ListItemComments control e.g. to a Forms Customizer or Webpart you built and configure it to update your item correctly
  2. Use following sample comments to reproduce
    2.1. This is a test \ repro
    2.2. This is a "Test"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions