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

cef

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cef - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

10

lib/cef.js

@@ -98,4 +98,12 @@ /**

sanitizeText: function sanitizeText(text) {
if (typeof text === 'undefined' || typeof text === 'null') {
text = typeof text;
}
else if (typeof text === 'object') {
text = JSON.stringify(text, null, 2);
}
// Make it a string
text = text.toString();
else text = text.toString();

@@ -102,0 +110,0 @@ // Escape pipes, backslashes, and equals signs that have not

2

package.json
{
"name": "cef",
"version": "0.3.1",
"version": "0.3.2",
"main" : "lib/cef.js",

@@ -5,0 +5,0 @@ "author": "Jed Parsons <https://github.com/jedp>",

@@ -6,56 +6,85 @@ var vows = require('vows');

function handles(input, expected) {
var context = {
topic: function() {
return this.context.name;
}
};
context["works"] = function(expected) {
return function(err) {
var formatter = new cef.Formatter();
assert(formatter.sanitizeText(input) === expected);
};
};
return context;
}
var suite = vows.describe("Formatter")
.addBatch({
"We escape": {
"The text sanitizer": {
topic: function() {
return (new cef.Formatter()).sanitizeText("|I=flan\r|you=pie\r\n");
var formatter = new cef.Formatter();
var f = formatter.sanitizeText;
return f(f(f("=I | like pie = glug\r\n\r\r\n")));
},
"pipes": function(text) {
assert(! /[^\\]\|/.test(text));
},
"is idempotent": function(text) {
assert(text === "\\=I \\| like pie \\= glug\n");
}
},
"equals signs": function(text) {
assert(! /[^\\]=/.test(text));
"Sanitizing a null value": {
topic: function() {
return (new cef.Formatter()).sanitizeText(null);
},
"backslashes": function(text) {
assert(! /[^\\]\\[^|=]/.test(text));
"yields 'null'": function(text) {
assert(text === 'null');
}
},
"The text sanitizer": {
"Sanitizing an undefined value": {
topic: function() {
var formatter = new cef.Formatter();
var f = formatter.sanitizeText;
console.log("apply f: " + f("glug| merg"));
return f(f(f("=I | like pie = glug\r\n\r\r\n")));
var foo = {};
return (new cef.Formatter()).sanitizeText(foo.undefined);
},
"is idempotent": function(text) {
assert(text === "\\=I \\| like pie \\= glug\n");
"yields 'undefined'": function(text) {
assert(text === 'undefined');
}
},
"The text sanitizer": {
"Sanitizing an object": {
topic: function() {
return (new cef.Formatter()).sanitizeText("|or else=");
var obj = {"I like": "pie"};
return (new cef.Formatter()).sanitizeText(obj);
},
"works on characters at string margins": function(text) {
assert(text === "\\|or else\\=");
"yields a valid JSON string": function(text) {
assert(JSON.parse(text)["I like"] === "pie");
}
},
"We collapse various newlines": {
"Sanitizing a number": {
topic: function() {
return (new cef.Formatter()).sanitizeText("I\r\n\r\nlike\r\r\rpie");
return (new cef.Formatter()).sanitizeText(42);
},
"to a single \n": function(text) {
assert(text === "I\nlike\npie");
"yields a string": function(text) {
assert(typeof text === 'string');
assert(text === "42");
}
},
"Sanitizing": {
"pipes": handles("eggman|walrus|", "eggman\\|walrus\\|"),
"equals signs": handles("2+2=4, 4+4=8", "2+2\\=4, 4+4\\=8"),
"backslashes": handles("C:\\blah\\blah", "C:\\\\blah\\\\blah"),
"special characters at string margins": handles("|or else=", "\\|or else\\="),
"multiple new-line characters": handles("I\r\n\r\nlike\r\r\rpie", "I\nlike\npie")
}
})
.addBatch({
"We ensure keys": {

@@ -62,0 +91,0 @@ topic: function() {

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