Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping of forward slash in JSON output method #530

Closed
michaelhkay opened this issue May 31, 2023 · 5 comments · Fixed by #942
Closed

Escaping of forward slash in JSON output method #530

michaelhkay opened this issue May 31, 2023 · 5 comments · Fixed by #942
Labels
Enhancement A change or improvement to an existing feature Serialization An issue related to the Serialization spec

Comments

@michaelhkay
Copy link
Contributor

The fact that we escape forward slash in the JSON output method has proved unpopular with quite a few users.

The rationale for doing it is discussed at https://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped

The short summary is that it's only needed when JSON is inserted into an HTML script element, and then only when immediately followed by >.

There's a workaround using character maps but it's really clumsy.

I don't want to escape forward slashes by default in the xdm-to-json() function because they appear so often in namespaces and it adds an awful lot of visual clutter. That means that our JSON formatter needs an option to suppress this escaping, which means we might as well provide user control over it as an output property...

Adding a new output property just for this purpose is rather heavyweight both in the specs and in our implementation, but I can't think of a better solution. So I propose adding escape-solidus, values yes/no, default (for compatibility) yes.

Yes, someone will ask about the name. Surely no-one calls it a solidus? Well, Unicode does, and I think we should use the official name. And it avoids arguing about whether it should be slash or forwards-slash or forward-slash. At least I'm not proposing virgule.

@michaelhkay michaelhkay added Enhancement A change or improvement to an existing feature Serialization An issue related to the Serialization spec labels May 31, 2023
@michaelhkay
Copy link
Contributor Author

This was addressed by PR #534 which was accepted.

@michaelhkay
Copy link
Contributor Author

Typo noted (3 times):

5.1.13 XML Output Method: the escape-solidus Parameter

The escape-uri-attributes parameter is not applicable to the XML ...

Also: we should add the escape-solidus option to the xml-to-json function

@ChristianGruen
Copy link
Contributor

@michaelhkay This issue can probably be closed… Unless we decide to rename escape-solidus to json-escape-solidus or escape-json-solidus (analogous to json-node-output-method). Otherwise, people might assume that the parameter affects other serialization methods as well.

@michaelhkay
Copy link
Contributor Author

The issue remains open, to correct the typo whereby the escape-solidus parameter is wrongly referred to as escape-uri-attributes

@michaelhkay michaelhkay added the PR Pending A PR has been raised to resolve this issue label Jan 10, 2024
@michaelhkay
Copy link
Contributor Author

PR #942 has been raised to fix the remaining typo.

@ndw ndw closed this as completed in #942 Jan 16, 2024
@ChristianGruen ChristianGruen removed the PR Pending A PR has been raised to resolve this issue label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement A change or improvement to an existing feature Serialization An issue related to the Serialization spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants