tag:blogger.com,1999:blog-34454975.post1742136638108479551..comments2023-06-28T16:58:41.189+02:00Comments on Web Reflection: isFunction hacked, isCallable solutionAndrea Giammarchihttp://www.blogger.com/profile/16277820774810688474noreply@blogger.comBlogger44125tag:blogger.com,1999:blog-34454975.post-44317557495475816602009-10-12T02:03:56.819+02:002009-10-12T02:03:56.819+02:00DBJ != AbozhilovDBJ != AbozhilovDBJDBJhttps://www.blogger.com/profile/10255157102936852683noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-42252783681996888922009-08-27T17:01:46.110+02:002009-08-27T17:01:46.110+02:00:))) You not guarantee "isCallable" retu...:))) You not guarantee "isCallable" return exactly "isCallable" :))) This is joke :))))<br />Maybe right name on your function is:<br />"isMaybeCallable" <br />Oh my good :))))Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-390738720335247202009-08-27T16:54:24.897+02:002009-08-27T16:54:24.897+02:00You don't answer my questions. That's enou...You don't answer my questions. That's enough!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-28322060246366996562009-08-27T16:45:33.498+02:002009-08-27T16:45:33.498+02:00nobody guarantee nothing with JS and I have never ...nobody guarantee nothing with JS and I have never said I guarantee something.<br /><br />This isCallable function simply tell you if you can call a function and after you have no idea how many other discussion about this and everywhere with whoever.<br /><br />You should read the old post, the jQuery dev discussion, visit the kangax website, understand the problem, be realistic about daily JavaScript environment, and only after this investigation, you can come back and discuss about my function, otherwise we both waist our time, OK?<br /><br />These are only suggestions, you can take them, you can ignore them keep talking like the last arrived JS dev wannabe, writing or confirming your mistakes and/or typos misunderstanding 9/10 of problems/features/reasons/etc,etc<br /><br />When you'll start to write something meaningful and pertinent I will reply without problems while If you want to ask something specific I will be happy to reply.<br /><br />RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-78474327887695213522009-08-27T15:56:50.080+02:002009-08-27T15:56:50.080+02:00I say you don't guarantee for your code!
What ...I say you don't guarantee for your code!<br />What are you thinking about DOM object :))) <br />Image <br />Option<br />Image.create method <br />Option.create methodAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-5783001975773947662009-08-27T14:56:45.826+02:002009-08-27T14:56:45.826+02:00copy and paste ... that's why you are here, ri...copy and paste ... that's why you are here, right?<br /><br />Ah ah ah, you are the most hilarious wannabe ever! Thanks to make my day :D<br /><br />P.S. I may result arrogant but for sure I do not post without understanding the code before, commenting it, and proposing solutions just to appear cool and skilled. If there is something I did not consider, I ask, and eventually I learn something, I do not keep bothering without valid reasons.<br /><br />Best RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-63015728028797211962009-08-27T14:29:49.468+02:002009-08-27T14:29:49.468+02:00You are yet another "copy/paste" man. I ...You are yet another "copy/paste" man. I don't wasting the time, with people like you! I never told. "I know JavaScript"... But you... You are arrogant fool! BB and i hope one day, me and you meeting anywhere.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-49741354189532941322009-08-27T14:21:44.971+02:002009-08-27T14:21:44.971+02:00listen, after this:
In JavaScript if object doesn...listen, after this:<br /><br /><i>In JavaScript if object doesn't not have that property __t__. Return undefined. In my code this safetly operation. If __t__ have any value, not changes.<br />I don't attach anything! Understand?</i><br /><br />which demonstrate how low is your JS level, I have nothing else to say and you neither but you do not learn.<br />You are a good throll indeed, and I find kinda funny to publish your deliriums, so please go on, you cannot get worse than this ;-)<br /><br />P.S. as rule, I always publish comments unless there is no spam and no offensive content. This is just WR netiquette. Have fun today, OK? I am going back to work nowAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-46142109399557297942009-08-27T14:13:22.647+02:002009-08-27T14:13:22.647+02:00Hm, this is shit.
Here JavaScript interpreter not ...Hm, this is shit.<br />Here JavaScript interpreter not optimize this operation. Ok one delete and we are ready :)))Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-56250784271944956232009-08-27T14:08:01.346+02:002009-08-27T14:08:01.346+02:00Oh my good... You don't understand basic Objec...Oh my good... You don't understand basic Object oriented concept and you tell us how to write code... Don't do this please. <br />Simple example with dummy exec method.<br /><br />Function.prototype.exec = function()<br />{<br /> this.call();<br />}<br /><br />function isFunction(sender)<br />{<br /> return Object.prototype.toString.call(sender) == '[object Function]';<br />}<br /><br />function tryThis(sender)<br />{<br /> var a = sender.contentWindow.alert;<br /> if (a instanceof Function)<br /> {<br /> a.exec();<br /> }<br /> if (isFunction(a))<br /> {<br /> a.exec();<br /> }<br />}<br /><br />What about this? Tell us, why in the second case when i use isFunction, my browser throw error?<br />And instanceof is the best way to check type of object. BB, and sometime is good idea thinking about problem. Not only copy/paste, that write Doug, Jhon or anything else...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-22109214675930199842009-08-27T13:53:32.930+02:002009-08-27T13:53:32.930+02:00The best way is toString from Object.prototype app...The best way is toString from Object.prototype applied to a possible callback to know if it returns "[object Function]"<br /><br />Secondly:<br /><i><br />var o = {};<br />o.__t__ = o.__t__;<br />for(var k in o)<br /> alert(k); // will alert __t__<br /></i><br /><br />you do not know JavaScript at all man, I already said do not embarrass yourself.<br />I am off man, but you can carry on by yourself if you like, bye.Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-1351077214075664672009-08-27T13:43:23.431+02:002009-08-27T13:43:23.431+02:00First error: instanceof
This is not error. In san...First error: instanceof <br />This is not error. In sandboxes Function is complete different object. Allright, i have question for you. Whats happen if you defined.<br />Function.prototype.new_member; <br />In sandbox we don't have, new_member. That say, this two object is complete different. And instanceof is best way for safe application from error in this case.<br /><br />Second error: c.__t__ = c.__t__<br />In JavaScript if object doesn't not have that property __t__. Return undefined. In my code this safetly operation. If __t__ have any value, not changes. <br />I don't attach anything! Understand? <br /><br />Third error: Public prototype. <br />Yes. Here you right.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-28290167963756765472009-08-27T13:22:53.998+02:002009-08-27T13:22:53.998+02:00abozhilov you cannot be serious, I am starting to ...abozhilov you cannot be serious, I am starting to think you are DBJ with a fake name.<br /><br />You completely "jumped" the part where your blaming analysis was wrong, as wrong is your solution.<br /><br />First error:<br /><i>c instanceof Function</i><br />With sandboxes (frames and iframes) isntanceof will always fail. You do not deeply understand the problem but you pretend to have a solution.<br /><br />Second error:<br /><i>!!(c.__t__ = c.__t__ && false)</i><br />you are assigning an obtrusive __t__ property to every object passed for your "solution" and you do not know that !!c.__t__ would have produced the same result in that expression. I call this bad code design.<br /><br />Third error:<br />You are acting in a hilarious way.<br />Nobody said JavaScript is secure, JS beauty is its malleability indeed.<br />If your point is that some idiot could redefine the RegExp.prototype.test method how can you propose this as fallback for your test?<br /><i>return !!String.prototype.indexOf.call(c, 'null');</i><br /><br />Please stop to embarrass yourself and consider that if I write or do some mistake I am ready to learn something new ... which is the difference between me and you I guess.<br /><br />Best RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-42286484260800857932009-08-27T13:07:21.305+02:002009-08-27T13:07:21.305+02:00"Your solution is not a solution, it is not t..."Your solution is not a solution, it is not testing the fact the object is callable, it is excluding a possible internal property from a prototype chain (double underscore as prefix/postfix is usually genuinely reserved for browsers)" <br /><br />Yes reserved for browsers. In your "solution", prototype chain is visible for all. And after this fact.<br />Whats happen, if i override test method of RegExp???? I broke your perfect code..... Because everything in RegExp.prototype is public. What is the Regular Expression concept? Maybe for testing type of object?!? <br /><br />Please, don't tell me, how i don't understand your "perfect" code. OK? You are another JavaScript "Guru", who tell us. Looked my code is "Capo di tutti capi".<br /><br />In conclusion, yours solution and my, is workaround on IE bug's. Do you guarantee for your code? Do you thing your code works well with everything native method and object in IE?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-47312496130308556202009-08-27T09:11:11.040+02:002009-08-27T09:11:11.040+02:00abozhilov, I have already fixed the function and n...abozhilov, I have already fixed the function and now I tell you why my bored answer OK?<br /><br />You pretended with a comment to tell me that my function is crap because "<i>Flanagan befre ... and attached properties after</i>"<br /><br />Both replies did not make sense and I was not attaching anything indeed.<br /><br />Your solution is not a solution, it is not testing the fact the object is callable, it is excluding a possible internal property from a prototype chain (double underscore as prefix/postfix is usually genuinely reserved for browsers) and it is extremely slow for both try catch usage plus zero in-closure shortcuts.<br /><br />So, what we discovered today?<br />That I simply forgot an explicit cast for weird cases (but thanks for your test case, that was sufficient to understand my function real problem) and that you had no idea why my function generated an error, but you had in any case to blame something I've never done before - attached properties - and me after, acting arrogant, pretending I am the one.<br /><br />Finally, you did exactly the same error <a href="http://groups.google.com/group/jquery-dev/browse_thread/thread/620c6a18a16d9665/f65074e139229f13?lnk=gst&q=bedge+object#msg_786cc697f205b076" rel="nofollow">somebody</a> did a while ago in jQuery dev list, replying without understanding the code.<br /><br />You want to come back with a different approach? You'll be more than than welcome!<br />You don't? Is not gonna be a massive lost for WebReflection if this is the way you suggest bugs or propose alternatives.<br /><br />RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-74940317917854733992009-08-27T03:12:55.702+02:002009-08-27T03:12:55.702+02:00Sorry, i forget one 'null' in last code:
/...Sorry, i forget one 'null' in last code:<br />//IE isCallable <br />Object.isCallable = function(c)<br />{<br /> try {<br /> return c instanceof Function || !!(c.__t__ = c.__t__ && false);<br /> }catch(e)<br /> {<br /> try {<br /> return !!String.prototype.indexOf.call(c, 'null');<br /> }catch(e){};<br /> return false;<br /> }<br />}<br /><br />So, why you so arrogant? I never go back here... To read your "perfect" code...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-54042925811117756942009-08-27T02:44:22.650+02:002009-08-27T02:44:22.650+02:00Now you tell me, my bugs :~)
//IE isCallable
Ob...Now you tell me, my bugs :~)<br />//IE isCallable <br />Object.isCallable = function(c)<br />{<br /> try {<br /> return c instanceof Function || !!(c.__t__ = c.__t__ && false);<br /> }catch(e)<br /> {<br /> try {<br /> return !!String.prototype.indexOf.call(c);<br /> }catch(e){};<br /> return false;<br /> }<br />}<br /><br />Gived one simple case, where i broke your browser or return strange value. <br />And i don't attach new property or values :))Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-68683742500755553752009-08-27T02:01:19.197+02:002009-08-27T02:01:19.197+02:00Adrea,
Try it please:
isCallable(new ActiveXObject...Adrea,<br />Try it please:<br />isCallable(new ActiveXObject('Microsoft.XMLHTTP'));<br /><br />This is harmful for my application...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-59761268367006422122009-08-27T01:33:30.345+02:002009-08-27T01:33:30.345+02:00abozhilov I wonder if rather than "just post&...abozhilov I wonder if rather than "just post" you read my code and tried it. It works with everything and I am not attaching anything. If not, please tell me a single case where my isCallable fails, thanks.<br /><br />Finally, I hope you are not just yet another new webreflection discoverer ... but you are acting like one.<br /><br />Regards.Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-71563861777757978742009-08-27T00:20:52.043+02:002009-08-27T00:20:52.043+02:00Try it yourself my solution, without RegExp:
//IE...Try it yourself my solution, without RegExp:<br /><br />//IE isCallable <br />Object.isCallable = function(c)<br />{<br /> if (!c) return false;<br /> if (c instanceof Function)<br /> {<br /> return true;<br /> }<br /> try {<br /> c.__call = c.__call;<br /> return false;<br /> }catch(e)<br /> {<br /> return true;<br /> }<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-8498455647828742382009-08-27T00:10:39.256+02:002009-08-27T00:10:39.256+02:00Andrea one tips:
Native method and host function ...Andrea one tips: <br />Native method and host function in IE, throw's error when you try to attach new property.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-59218045499665947232009-08-10T16:11:10.248+02:002009-08-10T16:11:10.248+02:00considering that an Object like this: { toString: ...considering that an Object like this: { toString: undefined, valueOf: undefined }<br />is both user created and something nobody will never use in a real case scenario, I am pretty much happy about the error results which aim is to block possible malicious objects to pass a function which aim is to make something callable for sure. In few words, aim reached, that object is not callable, which is better than a false positive, imho. If you use Function.prototype.call(HostObject) you could obtain same error in IE so I guess it is ok. Thanks in any case for that page test. RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-58565100133114092022009-08-10T15:24:22.276+02:002009-08-10T15:24:22.276+02:00http://dbj.org/3/eval.htm
We both have, different...http://dbj.org/3/eval.htm<br /><br />We both have, different versions.<br />Each err-ing on its own singularity.<br />Only in IE, of course...<br /><br />And. These both will "almost" work if function decomposition behaves "everywhere". Which somehow I do, not believe, same as http://thinkweb2.com/projects/prototype/those-tricky-functions/DBJDBJhttps://www.blogger.com/profile/10255157102936852683noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-38191020595838508862009-08-08T11:25:55.814+02:002009-08-08T11:25:55.814+02:00exactly, undefined is a non-safe check. that is li...exactly, undefined is a non-safe check. that is like var undefinedType = typeof undefined;<br /><br />RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-279002061584278172009-08-07T20:12:31.573+02:002009-08-07T20:12:31.573+02:00I found it confusing as well.
Not because I don&#...I found it confusing as well.<br /><br />Not because I don't understand left-to-right or anything like that, but simply because "typeof u" makes no sense (until I thought about it for a while).<br /><br />If it had been "u = typeof undefined;" I would have gotten it right away.<br /><br />Of course "u" is undefined, because you haven't assigned a value to it. But to outsiders looking at your code, it's very confusing. "typeof undefined", on the other hand, is not.<br /><br />My suggestion would be to place a comment, stating that it's the same as doing "typeof undefined". That comment would go a long way toward better understanding.<br /><br />Other than that one issue, it looks good. Just my 2 cents.<br /><br />P.S. I'm guessing you did "typeof u" rather than "typeof undefined" in case somebody decided they wanted to overwrite the value of "undefined"?Pauanhttps://www.blogger.com/profile/09141136258826180195noreply@blogger.com