Finish up #65 (lint and missing check)

This commit is contained in:
Mark Cavage 2012-03-14 09:06:03 -07:00
parent ac17609be8
commit d5cf19bd9e
3 changed files with 24 additions and 15 deletions

View File

@ -9,26 +9,28 @@
* (filename=C:\MyFile) (filename=C:\5cMyFile)
*
* Use substr_filter to avoid having * ecsaped.
*
* @author [Austin King](https://github.com/ozten)
*/
exports.escape = function (inp) {
if (typeof inp === 'string') {
var esc = "";
for (var i=0; i < inp.length; i++) {
if (typeof (inp) === 'string') {
var esc = '';
for (var i = 0; i < inp.length; i++) {
switch (inp[i]) {
case '*':
esc += "\\2a";
esc += '\\2a';
break;
case '(':
esc += "\\28";
esc += '\\28';
break;
case ')':
esc += "\\29";
esc += '\\29';
break;
case '\\':
esc += "\\5c";
esc += '\\5c';
break;
case '\0':
esc += "\\00";
esc += '\\00';
break;
default:
esc += inp[i];
@ -40,4 +42,4 @@ exports.escape = function (inp) {
} else {
return inp;
}
};
};

View File

@ -14,24 +14,30 @@ var Protocol = require('../protocol');
///--- API
function SubstringFilter(options) {
var _any;
if (typeof (options) === 'object') {
if (!options.attribute || typeof (options.attribute) !== 'string')
throw new TypeError('options.attribute (string) required');
this.attribute = escape(options.attribute);
this.initial = options.initial ? escape(options.initial) : null;
this.any = options.any ? options.any.slice(0) : [];
this['final'] = options['final'] || null;
_any = options.any ? options.any.slice(0) : [];
this['final'] = escape(options['final']) || null;
} else {
options = {};
}
if (!this.any)
this.any = [];
if (!_any)
_any = [];
this.any = [];
var self = this;
_any.forEach(function (a) {
self.any.push(escape(a));
});
options.type = Protocol.FILTER_SUBSTRINGS;
Filter.call(this, options);
var self = this;
this.__defineGetter__('json', function () {
return {
type: 'SubstringMatch',

View File

@ -1,10 +1,11 @@
{
"author": "Mark Cavage <mcavage@gmail.com>",
"contributors": [
"Craig Baker"
"Austin King <shout@ozten.com>"
"Mathieu Lecarme <mathieu@garambrogne.net>>",
"Trent Mick <trentm@gmail.com>",
"Yunong Xiao <yunong@joyent.com>",
"Craig Baker"
],
"name": "ldapjs",
"homepage": "http://ldapjs.org",