Right, I've rewritten how JSReg handles arrays. I now identify only when the [] is used as a property identifier and not an array. The RegExp works like this:-
squaresStart = new RegExp('(?:[\\)\\]]|'+variable.source+'|'+regexpObj.source+'|'+strings.source+')'),
So any matches that find a ")", string, variable, regexp followed by a "[" it will be rewritten as a object property. E.g.:-
'a'[0] // will be rewritten
(1)['__parent__'] // will be rewritten
/a/[1] // will be rewritten
x=[1,2,3]//will NOT be rewritten
([1,2,3,[1]])//will NOT be rewritten
This way I can make a fake lookbehind assertion without affecting the other matches as the arrays are left as they are. I've not benchmarked these regexps but they should be a lot faster now as I'm matching much less.
Here is an example on how to attack it:-
Й=1;
Й['__parent__']
Because I use a non alpha-num character as a variable you can get a reference to window. I plan to close this soon.
Update....
Fixed :)
Update2...
btw prototypes aren't working yet and the sandbox is still in the current window
------------------------------------------------------------------------------------------------------------
"People who say it cannot be done should not interrupt those who are doing it.";
labs : [
www.businessinfo.co.uk]
blog : [
www.thespanner.co.uk]
Hackvertor : [
hackvertor.co.uk]
Edited 2 time(s). Last edit at 08/06/2009 11:46AM by Gareth Heyes.