New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scratch-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scratch-parser - npm Package Compare versions

Comparing version 4.3.4 to 4.3.5

test/fixtures/data/217845144_sb2_control_char_in_strings_credit_to_Mr-Dave_test.json

8

lib/parse.js

@@ -13,3 +13,9 @@ /**

try {
result = JSON.parse(input);
// The input is a JSON string, which may contain control characters
// that should be removed. See LLK/scratch-vm#1077
// So far we've only encountered the backspace control character,
// so remove that specific one before continuing.
// SB2 JSONs and SB3 JSONs have different versions of the
// character serialized (e.g. \u0008 and \b), strip out both versions
result = JSON.parse(input.replace(/\\b|\\u0008/g, ''));
} catch (e) {

@@ -16,0 +22,0 @@ return callback(e.toString());

2

package.json

@@ -50,3 +50,3 @@ {

},
"version": "4.3.4"
"version": "4.3.5"
}

@@ -0,1 +1,3 @@

var fs = require('fs');
var path = require('path');
var test = require('tap').test;

@@ -27,1 +29,36 @@ var parse = require('../../lib/parse');

});
test('backspace control characters get stripped out in sb2', function (t) {
var backspaceControlSb2 = fs.readFileSync(
path.resolve(__dirname, '../fixtures/data/217845144_sb2_control_char_in_strings_credit_to_Mr-Dave_test.json'));
parse(backspaceControlSb2.toString(), function (err, res) {
t.equal(err, null);
t.type(res, 'object');
// Verify that the object doesn't have a control character in the global variable name
t.equal(Array.isArray(res.variables), true);
t.equal(res.variables.length, 1);
// The parsed string should no longer include a backspace control character
t.equal(res.variables[0].name, 'b-damage');
t.end();
});
});
test('backspace control characters get stripped out in sb3', function (t) {
var backspaceControlSb2 = fs.readFileSync(
path.resolve(__dirname, '../fixtures/data/217845144_sb3_control_char_in_strings_credit_to_Mr-Dave_test.json'));
parse(backspaceControlSb2.toString(), function (err, res) {
t.equal(err, null);
t.type(res, 'object');
// Verify that the object doesn't have a control character in the global variable name
t.equal(Array.isArray(res.targets), true);
t.equal(res.targets.length, 2);
t.type(res.targets[0].variables, 'object');
var backspaceControlVariableId = Object.keys(res.targets[0].variables)[0];
var backspaceControlVariable = res.targets[0].variables[backspaceControlVariableId];
// The parsed string should no longer include a backspace control character
t.equal(backspaceControlVariable[0], 'b-damage');
t.end();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc