Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-stringprep

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-stringprep - npm Package Compare versions

Comparing version 0.1.12 to 0.2.0

.jshintrc

71

index.js

@@ -1,1 +0,70 @@

module.exports = require('bindings')('node_stringprep.node')
'use strict';
try {
var bindings = require('bindings')('node_stringprep.node')
} catch (ex) {
console.warn(
'Cannot load StringPrep-' +
require('./package.json').version +
' bindings (using fallback). You may need to ' +
'`npm install node-stringprep`'
)
}
var toUnicode = function(value) {
try {
return bindings.toUnicode(value)
} catch (e) {
return value
}
}
var StringPrep = function(operation) {
this.operation = operation
try {
this.stringPrep = new bindings.StringPrep(this.operation)
} catch (e) {
this.stringPrep = null
}
}
StringPrep.prototype.UNKNOWN_PROFILE_TYPE = 'Unknown profile type'
StringPrep.prototype.UNHANDLED_FALLBACK = 'Unhandled JS fallback'
StringPrep.prototype.prepare = function(value) {
this.value = value
try {
if (this.stringPrep) {
return this.stringPrep.prepare(this.value)
}
} catch (e) {}
return this.jsFallback()
}
StringPrep.prototype.jsFallback = function() {
switch (this.operation) {
case 'nameprep':
case 'nodeprep':
return this.value.toLowerCase()
case 'resourceprep':
return this.value
case 'nfs4_cs_prep':
case 'nfs4_cis_prep':
case 'nfs4_mixed_prep prefix':
case 'nfs4_mixed_prep suffix':
case 'iscsi':
case 'mib':
case 'saslprep':
case 'trace':
case 'ldap':
case 'ldapci':
throw new Error(this.UNHANDLED_FALLBACK)
default:
throw new Error(this.UNKNOWN_PROFILE_TYPE)
}
}
module.exports = {
toUnicode: toUnicode,
StringPrep: StringPrep
}

12

package.json
{
"name": "node-stringprep",
"version": "0.1.12",
"version": "0.2.0",
"main": "index.js",

@@ -12,3 +12,3 @@ "description": "ICU StringPrep profiles",

"scripts": {
"test": "node test/leakcheck.js"
"test": "grunt test"
},

@@ -19,3 +19,9 @@ "dependencies": {

},
"devDependencies": {},
"devDependencies": {
"proxyquire": "~0.5.2",
"grunt-mocha-cli": "~1.3.0",
"grunt-contrib-jshint": "~0.7.2",
"should": "~2.1.1",
"grunt": "~0.4.2"
},
"repository": {

@@ -22,0 +28,0 @@ "type": "git",

@@ -1,21 +0,17 @@

var SP = require('../index')
var next = global.setImmediate
? function () { setImmediate(run) }
: function () { process.nextTick(run) }
'use strict';
function run() {
var p = new SP.StringPrep('nameprep')
var r = p.prepare('A\u0308ffin')
if (r !== 'äffin')
throw r
next()
}
require('should')
try {
run()
console.log('Success')
process.exit(0)
} catch (e) {
console.log(e.stack)
process.exit(1)
}
it('Should not leak', function(done) {
var SP = require('../index')
try {
var p = new SP.StringPrep('nameprep')
var result = p.prepare('A\u0308ffin')
result.should.equal('äffin')
done()
} catch (e) {
done(e)
}
})
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