Make sure 'print' is not used directly in envjs
Reported by nickg | March 21st, 2010 @ 12:36 PM
A webpage from a Large Site had this tidbit.
function print(pageName) {
window.open(pageName, "Print", "scrollbars=yes,menubar=yes,resizable=yes,width=680,height=430,top=125,left=325");
}
print('foo');
If you run this, envjs exhausts all memory and explodes depending how you have it configured since it can go into an infinite loop. This was not fun tracing or debugging. Boo.
Redefining print
aka window.print
is
legit, so one could do this type of switcheroo:
Envjs.print = print
Then make sure anyone who uses print
calls
Envjs.print
instead. OR use console.log and make sure
does the equiv (i.e. Console.print = print).
Really this might be more a documentation issue than a code issue, since print should be used in very few places, but the API/callbacks might use it, causing my infinite loop.
Comments and changes to this ticket
-
nickg March 21st, 2010 @ 02:41 PM
- State changed from new to open
This is easier than I expected since the groundwork has already been laid. All that needs to change is in
src/platform/rhino/console.js
Envjs.log = function(msg) { print(msg); }
to
Envjs.log = print;
console
callsEnvjs.log
instead of usingprint
directly (nice work whoever did this. Thank you!).I'll let this bake for a bit to see if anyone has objections/comments.
--nickg
-
nickg March 27th, 2010 @ 04:41 AM
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
a javascript browser environment