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

ldap-filters

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-filters - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

2

beautify.js

@@ -9,2 +9,2 @@ var Filter = require('./index');

console.log(parsed + '');
console.log(parsed.toString(true));
console.log(parsed.toString(true,null,false));

@@ -30,8 +30,19 @@ var soundex = require('soundex');

},
toString: function(indent,level) {
_indent: function(indent,level,id_char){
var _i = parseInt(indent);
if (indent === true) indent = Filter.indent;
else if (parseInt(indent) < 1) indent = 0;
else if (!isNaN(_i)) indent = _i;
else return '';
if ((id_char !== undefined) && (typeof id_char != 'string'))
throw new Error('Indent string must be string');
level = level || 0;
id_char = id_char || Filter.indent_char;
return id_char.repeat(level*indent);
},
toString: function(indent,level,id_char) {
return [
' '.repeat(level*indent),
this._indent(indent,level,id_char),
'(', this.attrib, this.comp, this.value, ')'

@@ -45,4 +56,5 @@ ].join('');

/* Default indent for beautify */
/* Default indent and character for beautify */
Filter.indent = 4;
Filter.indent_char = ' ';

@@ -53,9 +65,7 @@ /* Escape a string value */

if (!value) return '';
for(var i=0,l=value.length; i<l; i++){
rv.push(
(Filter.escapeChars.indexOf(value[i]) >= 0)?
'\\'+value.charCodeAt(i).toString(16): value[i]
);
}
return rv.join('');
return value.split('').map(function(c){
return(Filter.escapeChars.indexOf(c) >= 0)?
'\\'+c.charCodeAt(0).toString(16): c
}).join('');
};

@@ -145,19 +155,16 @@

Group.prototype = {
match: function(data){
return this._match(data);
},
toString: function(indent,level){
if (indent === true) indent = Filter.indent;
else if (parseInt(indent) < 1) indent = 0;
var nl = indent ? '\n': '';
level = level || 0;
return ' '.repeat(level*indent) +
'(' + this.comp + nl +
this.filters.map(function(item){
return item.toString(indent,level+1)
}).join(nl) + nl + ' '.repeat(level*indent) +
')';
}
Group.prototype = Object.create(Filter.prototype);
Group.prototype.match = function(data){
return this._match(data);
};
Group.prototype.toString = function(indent,level,id_char){
level = level || 0;
var id_str = this._indent(indent,level,id_char);
var nl = indent? '\n': '';
return [
id_str, '(', this.comp, nl, this.filters.map(function(item){
return item.toString(indent,level+1,id_char)
}).join(nl), nl, id_str, ')'
].join('');
};

@@ -164,0 +171,0 @@ var GroupOr = function(filters) {

{
"name": "ldap-filters",
"version": "1.0.2",
"version": "1.1.0",
"description": "Library for generating, parsing, and evaluating LDAP filters",

@@ -14,3 +14,4 @@ "main": "index.js",

"scripts": {
"test": "mocha --timeout 5000 test/*js"
"test": "mocha --timeout 5000 test/*js",
"build": "jison lib/parser.jison -o lib/parser.js"
},

@@ -17,0 +18,0 @@ "repository": {

@@ -75,4 +75,4 @@ node-ldap-filters

query.toString()
query + ''
filter.toString()
filter + ''

@@ -83,9 +83,9 @@ This will result in compacted output with no whitespace like:

If you pass a value of `true` or a numeric value to `toString()`, the
output will be beautified:
If you pass a value of `true` or a numeric indentation value to
`toString()`, the output will be beautified with space indentation.
query.toString(true)
query.toString(2)
filter.toString(true)
filter.toString(2)
Will result in similar output to the following output:
Will result in similar output to the following:

@@ -104,2 +104,3 @@ ```

A value of `true` will use `Filter.indent` property, which defaults to 4.
The indentation character defaults to a space, see `Filter.indent_char`

@@ -137,5 +138,2 @@ ### Evaluate data against a filter

# Run tests with "make"
make test
# Run tests manually

@@ -154,4 +152,4 @@ mocha test/*.js

# Build with "make"
make parser
# Build parser with npm
npm run build

@@ -158,0 +156,0 @@ # Build manually with jison

@@ -34,4 +34,28 @@ var should = require('chai').should();

});
it('indents with custom string',function(done){
parsed.toString(2,null,'\t').should.be.equal(
'(&\n\t\t(givenName=jenny)\n\t\t(sn=jensen)\n\t\t(|\n\t\t\t\t(c=us)\n\t\t\t\t(st=ontario)\n\t\t)\n)'
);
done();
});
it('indents with custom string (global setting)',function(done){
var old = Filter.indent_char;
Filter.indent_char = '\t';
parsed.toString(2).should.be.equal(
'(&\n\t\t(givenName=jenny)\n\t\t(sn=jensen)\n\t\t(|\n\t\t\t\t(c=us)\n\t\t\t\t(st=ontario)\n\t\t)\n)'
);
Filter.indent_char = old;
done();
});
it('fails if indent string not a string',function(done){
assert.throws(function(){
parsed.toString(2,null,1);
}, Error);
done();
});
});
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