Plugin Readme: http://bit.ly/ie4J04
First, and most importantly - I have added a series of static methods (that look similar to the methods on the Encoder interface for ESAPI) to perform particular contextual encoding tasks - specifically when building html dynamically rather than building elements up using the DOM.
- encodeForHTML
- encodeForHTMLAttribute
- encodeForCSS
- encodeForURL
- encodeForJavascript
Each of these methods can be accessed under the static
$.encoder
context. $.post('http://untrusted.com/external_profile', function(profile) { $('#widget').html('<div id="untrusted_widget" width="' + $.encoder.encodeForHTMLAttribute(profile.width) + '" onmouseover="' + profile.callback + "(\'' + $.encoder.encodeForJavascript(profile.parm) + '\')">' + $.encoder.encodeForHTML(profile.data) + '</div>'); }
In addition, the
$.canonicalize
method has also been moved into the $.encoder
context. $('#phonenumber').blur(function() { validatePhoneNumber($.encoder.canonicalize(this.val()); });
The third, and final big change over the weekend - was solidifying the ES5 immutable objects protection. If it is supported by the browser, the
$.encoder
object will be frozen, sealed, or non-extensible (in that order of priority) to protect the encoding and canonicalize functions themselves from being tampered with at runtime. At this point in time, Chrome has implemented Object.freeze
in the latest release version, Mozilla has implemented it in Firefox 4 and Microsoft have implemented it in IE9. Safari shows no indication of implementing it, and neither does Opera.Now, I pose a question to the developers that may use this plugin. Is there a need to keep the instance method
$.fn.encode
? It seems to me that due to the nature of setting DOM element properties via Javascript, that this is not really needed at all. So, should I nuke it?I end this post with a final thought (continuing from my above conversation of Object.freeze)
I strongly recommend that developers start taking the initiative to make their custom JS objects immutable, and also recommend making framework objects immutable as well. If you were to (using jQuery) issue the following in your onready handler
$(document).ready(function(){ if ( Object.freeze ) $ = Object.freeze($); // .. initialize page below here });
It seems to me, this could eliminate a lot of potential vulnerability exploitation of bugs in framework code. What are your thoughts?
Also, why not consider the following:
var lock_objs = [ String.prototype, Array.prototype, Function.prototype, Object.prototype ]; for (var i=0;i<lock_objs.length;i++) lock_objs[i] = Object.freeze(lock_objs[i]);
Once again great post. You seem to have a good understanding of these themes.When I entering your blog,I felt this . Come on and keep writting your blog will be more attractive. To Your Success!
ReplyDeleteClassic Dresses
Classic Bridesmaid Dresses
Wedding Dresses with Sleeves
Flower Girl Dresses
Empire Wedding Dresses
Good article.I really think what you said is right,in modern society,we have so many troubles,if you feel nothing to relax yourself,I suggest you to play the wow and some other games,and you can come to my page to find more information about http//www.mmolive.com/ andhttp://www.mmohome.com/gold/Maple-Story-US.html
ReplyDeleteYou can easily order your Guild Wars 2 Gold on our website. Guildwars2buygold guarantees quality and quickness. Just choose the desired amount of GW2 Gold, your server and send the order.After order paid, please contact our livechat to get your delivery.You will receive your Guild wars 2 Gold from here mostly within a few hours after order confirmed. Delivery of the cheap Guild Wars 2 Gold via trading face to face in game.
ReplyDeletesalam kenal bos. lagi jalan jalan pagi nih
ReplyDeleteIt is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteBest Devops Training in pune
Devops Training in Bangalore
Microsoft azure training in Bangalore
Power bi training in Chennai
for Data Science training in bangalore, Visit:
ReplyDeleteData Science training in bangalore
Such a good post .thanks for sharing
ReplyDeleteIELTS Training in T Nagar
IELTS Training in T Nagar
kralbet
ReplyDeletebetpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
betmatik
H4MZB