Permalink
Browse files

Correction eval/fixURI - add regexp for node-gadgets node-bot

  • Loading branch information...
1 parent 276f059 commit f31334ab1e54dce577330e17ea4bc68e0f81e917 @Ayms committed Dec 6, 2011
Showing with 12 additions and 10 deletions.
  1. +12 −10 lib/browser/index.js
View
@@ -40,7 +40,7 @@ Function.prototype.De=function(obj,_name,_node) {
//Probably to remove
var fixURI=function(url) {
//return url;
- var re=/%253B|%252C|%252F%253F|253A|%2540|%2526|%253D|%252B|%2524|%2523/g;
+ var re=/%253B|%252C|%252F%253F|%253A|%2540|%2526|%253D|%252B|%2524|%2523/g;
if (url) {
url=encodeURI(decodeURI(url));
/*Example : http://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221%22%2C%22callback%22%3A%22getTradTags%22%2C%22language%22%3A%22"+mylang+"%22%2C%22nocss%22%3A%22true%22%7D%5D%7D
@@ -57,7 +57,7 @@ var fixURI=function(url) {
score -> #
*/
- url=url.replace(re,function(val) {return val.replace(/%25/,'%')});
+ url=url.replace(re,function(val) {return val.replace(/25/,'')});
}
return url;
@@ -82,10 +82,9 @@ var canon=function(attr){ //border-color --> borderColor
return attr.replace(/-\D/g,function(match){return match.charAt(1).toUpperCase();});
};
-var __cc=function(node) {
+var __cc=function(node,regexp) {
var str = node.__data.toString().replace(/^\s+/g,'').replace(/\s+$/g,'') ;
- var reprix0 = /руб|\$||£||¥|Ұ|||||EUR|USD|CHF/g;
- if (str.match(reprix0)){
+ if (regexp.test(str)){
return true;
};
return false;
@@ -231,6 +230,7 @@ core.resourceLoader = {
case 'style': src='';break;
default : return;
};
+
if (src) {
element._href=src;
src = URL.parse(src);
@@ -416,7 +416,7 @@ core.resourceLoader = {
};
};
-
+
if (name=='script') {
this.write(element);
@@ -694,6 +694,7 @@ core.Node.prototype={
return this._document;
},
insertBefore : function(node,before) {
+
var children=this.__children;
if (before!=null) {
@@ -721,8 +722,8 @@ core.Node.prototype={
};
if ((node.__type=='text')&&(this._document.readyState!='complete')) {
- if (!(this.__name in NOCONT)) {
- if (__cc(node)) {
+ if ((!(this.__name in NOCONT))&&(node._document._regexp)) {
+ if (__cc(node,node._document._regexp)) {
this._document._parentNode._ewList.push(node);
};
};
@@ -1814,7 +1815,7 @@ var DOMWindow=function(document) {
};
this.eval=function(str) { //Make sure eval does execute in window context (xhr result for example)
- core.languageProcessors['javascript'](self,str,'');
+ return core.languageProcessors['javascript'](self,str,'');
};
this.parentNode=this;
this.document=this._document;
@@ -1969,7 +1970,8 @@ core.HTMLDocument=function(parser,options) {
this.head=false;
this._base='';
this._options=options;
- this._features=options.features||{FetchExternalResources:{},ProcessExternalResources:{},removeScript:false};
+ this._features=options.features||{FetchExternalResources:{},ProcessExternalResources:{},removeScript:false,regexp:''};
+ this._regexp=this._features.regexp?new RegExp(this._features.regexp,"g"):'';//double \ if included in regexp
this._URL=options.url.href||'';
this._queue=[];
this._queueimg=[];

0 comments on commit f31334a

Please sign in to comment.