Skip to content

JSON fixtures with unicode escape sequences are not parsed correctly #964

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

Closed
vschoettke opened this issue Nov 27, 2017 · 3 comments
Closed
Assignees
Labels
pkg/server This is due to an issue in the packages/server directory type: bug
Milestone

Comments

@vschoettke
Copy link

vschoettke commented Nov 27, 2017

See the "Current behavior" for bug details.

I already boiled the problem down to an error in the jsonlint module that is used for parsing the JSON data in

.then(jsonlint.parse)
and filed and issue there (zaach/jsonlint#102), but because that last commit is 3 years ago I don't know if it's still maintained.

Returning the result of JSON.parse() if no jsonlint error happened will fix the error while still keeping jsonlint as validator.

  • Operating System: MacOS 10.13.1
  • Cypress Version: 1.1.2
  • Browser Version: not relevant

Is this a Feature or Bug?

This is a bug.

Current behavior:

A JSON file that contains unicode escape sequences (\uXXXX) in string values is not parsed correctly ("\uXXXX" results in "\uXXXX").

Desired behavior:

JSON fixture is parsed correctly.

How to reproduce:

See https://github.com/vschoettke/cypress_fixture_parse_bug for an example

Test code:

fixtures/test_error.json

{
    "name": "\u30d0\u30b0"
}

integration/test_spec.js

describe("cypress should load json fixture with unicode specifier correctly", () => {
    it("should decode correctly", () => {
        cy.server();
        cy.fixture("test_error.json").then((data) => {
            const realData = require("../fixtures/test_error.json");
            expect(data.name).to.equal(realData.name);
        });
    });
});
@bahmutov bahmutov added stage: needs investigating Someone from Cypress needs to look at this type: bug labels Nov 27, 2017
@bahmutov
Copy link
Contributor

Might switch to updated fork https://github.com/circlecell/jsonlint-mod or just use JSON.parse

@bahmutov
Copy link
Contributor

Yeah, seems it is escaping the slash, so it does not process unicode JSON fixtures correctly.

@bahmutov bahmutov self-assigned this Nov 27, 2017
@bahmutov bahmutov added pkg/server This is due to an issue in the packages/server directory and removed stage: needs investigating Someone from Cypress needs to look at this labels Nov 27, 2017
@brian-mann brian-mann added this to the 1.1.3 milestone Nov 29, 2017
@brian-mann
Copy link
Member

Released in 1.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/server This is due to an issue in the packages/server directory type: bug
Projects
None yet
Development

No branches or pull requests

3 participants