-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
HttpUtility.JavaScriptStringEncode single quote behavior does not match documentation #100248
Comments
Tagging subscribers to this area: @dotnet/ncl |
I think the behavior here is correct, |
Do you have more details on this behavior? When I type Or maybe I've misunderstood entirely and we're talking about C# string literals? Edit: I think this is the relevant grammar production in the ecmascript spec. |
Ah, looks like I was looking at JSON, which defines the same set except for |
While that does seem plausible, the code already escapes |
Right, I'm suggesting we don't change the behavior here and update the docs instead since over-escaping is fine in JSON (and should be in JS strings as well?). |
My turn to get mixed up. 😆 I forgot what the current state was. Yes, I think I'd agree that a doc update makes more sense. I kind of wish we had escaped single quote "properly" in the first place, but that ship has sailed. |
…ch with the implementation dotnet/runtime#100248
Is there an existing issue for this?
Describe the bug
The documentation for HttpUtility.JavaScriptStringEncode states that the single quote character (') will be escaped as \'.
However, it gets escaped as \u0027.
Double quote is escaped as the documentation describes.
Expected Behavior
Expected that HttpUtility.JavaScriptStringEncode functions as documented.
Steps To Reproduce
Pass a string containing a single quote character (') to HttpUtility.JavaScriptStringEncode.
Here is a .NET fiddle displaying this behavior.
Exceptions (if any)
No response
.NET Version
8.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: