Permalink
Browse files

reviewed arguments checking in the 'select' method

  • Loading branch information...
1 parent d5f1005 commit 827b13ff672a76bbe6223024d5bbee7d55ae89a0 @dperini committed Dec 3, 2012
Showing with 10 additions and 10 deletions.
  1. +5 −5 src/nwmatcher-base.js
  2. +5 −5 src/nwmatcher.js
View
@@ -485,15 +485,15 @@
var i, changed, element, elements, parts, token, original = selector;
if (arguments.length === 0) {
- emit('Missing required selector parameters');
- return [ ];
- } else if (selector === '') {
- emit('Empty selector string');
+ emit('Not enough arguments');
return [ ];
} else if (typeof selector != 'string') {
return [ ];
+ } else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) {
+ emit('Invalid or illegal selector string');
+ return [ ];
} else if (from && !(/1|9|11/).test(from.nodeType)) {
- emit('Invalid context element');
+ emit('Invalid or illegal context element');
return [ ];
} else if (lastContext !== from) {
switchContext(from || (from = doc));
View
@@ -1330,15 +1330,15 @@
var i, changed, element, elements, parts, token, original = selector;
if (arguments.length === 0) {
- emit('Missing required selector parameters');
- return [ ];
- } else if (selector === '') {
- emit('Empty selector string');
+ emit('Not enough arguments');
return [ ];
} else if (typeof selector != 'string') {
return [ ];
+ } else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) {
+ emit('Invalid or illegal selector string');
+ return [ ];
} else if (from && !(/1|9|11/).test(from.nodeType)) {
- emit('Invalid context element');
+ emit('Invalid or illegal context element');
return [ ];
} else if (lastContext !== from) {
// reset context data when it changes

0 comments on commit 827b13f

Please sign in to comment.