Page MenuHomePhabricator

invalid JSON when copy-pasting to create a new implementation
Closed, DuplicatePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Tab 1: open https://www.wikifunctions.org/view/en/Z21995
  • Tab 2: open https://www.wikifunctions.org/view/en/Z21642
  • In Tab 2, click the + next to implementations to create a new implementation, then switch to code, and choose javascript
  • In Tab 1 In the code section (not editing, just viewing), select (ctrl-a) and copy (ctrl-c) all the code.
  • In Tab 2, in the code box, select all (ctrl-a) to highlight the auto-generated function template, then paste the code already copied from Tab 1 to replace it (ctrl-v). Then press publish, enter a comment, and publish again.

What happens?:
"Invalid JSON"

image.png (522×367 px, 17 KB)

What should have happened instead?:
It should just save?

Other information (browser name/version, screenshots, etc.):
The other day I could get around this by pre-saving the empty function template, then editing again and now pasting the code which allowed publication.

Event Timeline

I bet it's a character escaping issue. That implementation has a lot of regex so it's likely that one of those is being incorrectly read.

I bet it's a character escaping issue. That implementation has a lot of regex so it's likely that one of those is being incorrectly read.

Can confirm this, it went through when I simply removed both regexes.

This was the same issue as T413466 (backslashes in code lost by replaceNullReferencePlaceholder() on creation), which we fixed in January. Sorry for not joining up the dots beforehand.