-
24 Nov 2006 2:10 PM #1
Element.update() and loadScripts...
Element.update() and loadScripts...
Turned out the regex still wasn't there. It was greedy in matching the ([\'\"]) pattern, and in the string <script src="foo" type="text/javascript"></script> if would extract the source as 'foo" type="text/javascript"'
Also, on the else side of the srcMatch, match[1] is always true for valid script tags - it's a string, but zero length, so I added a length check:
Code:YAHOO.util.Event.onAvailable(id, function(){ var hd = document.getElementsByTagName("head")[0]; var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img; var srcRe = /\ssrc=[\'\"]([^\'\"]*)[\'\"]/i; // <------ this changed var match; while(match = re.exec(html)){ var srcMatch = match[0].match(srcRe); if(srcMatch && srcMatch[1]){ var s0 = document.createElement("script"); s0.src = srcMatch[1]; hd.appendChild(s0); }else if(match[1] && (match[1].length != 0)){ //<----- this changed too eval(match[1]); } } var el = document.getElementById(id); if(el){el.parentNode.removeChild(el);} if(typeof callback == 'function'){ callback(); } });
-
24 Nov 2006 4:57 PM #2
Damn, I wish I would have found these before the release. That sucks.
-
25 Nov 2006 1:28 AM #3
Well, I guess I should have tested with the src and type attributes the other way round when I did my initial testing too!
-
25 Nov 2006 10:38 AM #4
In fact, the regex to extract the src should be
The "?" after the .* makes it reluctant rather than greedy, so it stops at the first occurrence of capture group 1 (' or ").Code:/\ssrc=([\'\"])(.*?)\1/i
Obviously then, the src is in match[2]
-
25 Nov 2006 4:23 PM #5
I'm ahead of ya. I didn't use the back reference but using it makes sense.
-
26 Nov 2006 6:22 AM #6
In fact using the backreference method to delimit the src="" string, I'm sure you could get the script search for both src URLs and source code content back into one regex! Hours of fun for the geekly minded........ I'll have a play! :lol:
-
6 Dec 2006 5:03 AM #7
fix hasn't made it into 33-rc3?
fix hasn't made it into 33-rc3?
ran into the same problem. wondering if the fix will make it's way into the rc4 or final 33 release? currently using rc3. thanks / matthew
-
6 Dec 2006 5:46 AM #8
I'm not seeing the problem in RC3
-
8 Dec 2006 12:04 AM #9
regular expression switched but have to pull srcMatch[2]
regular expression switched but have to pull srcMatch[2]
hej,
saw that the regular expression for srcRe was replaced between rc2 and rc3 but the src property gets set to blank if the srcMatch[1] item is pulled. had to pull srcMatch[2] instead (regardless of the order of script tag attributes).
-
9 Dec 2006 7:08 AM #10
It should be 2, the 1st match is the quote. I will be doing a bug fix release to correct this and other rc3 bugs this weekend.
Similar Threads
-
Element.update() && styles
By vtswingkid in forum Ext 1.x: BugsReplies: 11Last Post: 21 Jun 2007, 5:29 AM -
Element.update()
By Animal in forum Ext 1.x: BugsReplies: 1Last Post: 23 Oct 2006, 12:59 PM


Reply With Quote