Skip to main content

Bug Tracker

Side navigation

#12357 closed bug (fixed)

Opened August 20, 2012 10:10PM UTC

Closed October 01, 2012 12:57AM UTC

Last modified October 21, 2012 12:51AM UTC

jQuery 1.8.0 Not parseable by XUL Runner Applications

Reported by: brandon@1942design.com Owned by: gibson042
Priority: low Milestone: 1.8.3
Component: support Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:
Description

jQuery 1.8.0 usage of <tag> and other unescaped "<" character combinations has resulted in the inability for XUL Runner Applications to parse the jQuery core code and insert it into the dom.

up until jQuery 1.7.2 XUL Runner Apps were able to parse the javascript normally.

You can test this by setting up a simple xul runner window and including jQuery, then alert the typeof jQuery or $ which will result in a response of undefined.

If you paste the jQuery code into a script tag in the XUL main window, you will be able to see all the various parsing issues that have been released in this build.

Attachments (0)
Change History (27)

Changed August 20, 2012 10:28PM UTC by dmethvin comment:1

owner: → brandon@1942design.com
status: newpending

Can you provide an example of what you're talking about? We're kind of busy here at jQuery Central and https://www.google.com/search?q=setting+up+a+simple+xul+runner+window doesn't seem like a five-minute job.

Changed August 21, 2012 12:30PM UTC by dmethvin comment:2

resolution: → duplicate
status: pendingclosed

Duplicate of #12359.Seems like this is a dup of #12359, which does a good job of identifying the problem.

Changed August 21, 2012 02:18PM UTC by Brandon Nosaki Miller comment:3

This is not a duplicate the issue is completely different than #12359 also this issue does stop execution. I am compiling package of screen shots for you along with a compiled xul app which will pull in an external jQuery file for debugging.

Changed August 21, 2012 06:45PM UTC by dmethvin comment:4

I think it may have the same root cause, which is that our use of .innerHTML in several places is not valid XHTML at the moment. Which lines are causing trouble?

Also see #10198 where we are trying to figure out a way to test this to prevent future regressions. Maybe your app could be used in our test suite if we can figure a way to integrate it.

Changed August 21, 2012 07:12PM UTC by anonymous comment:5

Starts with this line

Parsing Error:

Location: chrome://myapp/content/main.xul

Prioritize #id over <tag> to avoid XSS via location.hash (#9521)

once removed it moves on to :

Parsing Error: not well-formed

Location: chrome:myapp/content/main.xul

rquickExpr = /^(?:[^#<]*(<[\\w\\W]+>)[^>]*$|#([\\w\\-]*)$)/,

once updated to = moves on to :

Parsing Error: not well-formed

Location: chrome:myapp/content/main.xul

rsingleTag = /^<(\\w+)\\s*\\/?>(?:<\\/\\1>|)$/,

once updated to = moves on to :

Parsing Error: not well-formed

Location: chrome:myapp/content/main.xul

if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {

The common issue seems to be the tag open close chars, however this was not an issue in 1.7.2

Changed August 21, 2012 07:14PM UTC by Brandon Nozaki Miller comment:6

here is a version of what I am working with, sorry, it is built for windows right now.

http://uploadbin.net/502d8a88ebc311e1baaad1d1a5c7f576/Digi+Now+Jukebox.rar

the main.xul exsists in the chrome/content/ dir

Changed August 27, 2012 04:49PM UTC by dmethvin comment:7

@brandon, can you try your code with http://code.jquery.com/jquery-git.js and let us know if the problem has been fixed? Thanks!

Changed August 27, 2012 05:29PM UTC by anonymous comment:8

No, still the same issue, I believe it has something to do with the use of the open and close tag character. Has this changed since 1.7.2?

Specifically in the comments in areas like "<tag>" and or in regex's like /[<|>]/

Changed August 28, 2012 02:51AM UTC by dmethvin comment:9

resolution: duplicate
status: closedreopened

Oh I see comment 5 now and agree it's not a dup. This seems like XUL Runner is totally wrong. Why is it trying to parse comments and RegExp in the Javascript source? Many of those were in 1.7.2 as well.

Changed August 28, 2012 02:57AM UTC by dmethvin comment:10

status: reopenedpending

I'm looking at that main.xul file and it looks incorrect. Shouldn't real XML have CDATA wrapping the script?

<window id="main" title="DigiNow Jukebox" width="900" height="700" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    
	<script>
		/*!
 * jQuery JavaScript Library v1.8.0
 * http://jquery.com/
... etc ...

Changed August 28, 2012 03:34AM UTC by brandon@1942design.com comment:11

status: pendingnew

CDATA still does not fix the issue :(, even if it did it would mean private hosting of CDATA wrapped jQuery would have been needed not public CDN hosted.

Notice here with a script include, you can not use CDATA, however, this is jQuery 1.7.2 and you will get to the alert($);

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="DigiNow Jukebox" width="900" height="700" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script>
alert(1);
	</script>
	
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	
	<script>
alert($);
	</script>
	
</window>

on the other hand :

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="DigiNow Jukebox" width="900" height="700" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script>
alert(1);
	</script>
	
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
	
	<script>
alert($);
	</script>
	
</window>

loading in the newest version, or specifying 1.8.0 you will cause a fatal error.

SUPER INTERESTINGLY ENOUGH

I did wrap in 1.8 in CDATA and added an error handler

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="DigiNow Jukebox" width="900" height="700" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script>
	window.onerror=function(e){
 alert(e)
}
alert(1);
	</script>
	
	<script>
		<![CDATA[
		
		/*! jQuery v@1.8.0 jquery.com | jquery.org/license */

blah blah blah jquery mumbo jumbo magic stuff here ....


]]>
	</script>
	
	<script>
alert($);
	</script>
	
</window>

and I got the error : d is not defined

followed by the expected $ is not defined since jQuery failed to initialize.

Changed August 28, 2012 03:41AM UTC by dmethvin comment:12

status: newpending

It seems like there are multiple confusing things here.

Your example file in the .rar had jquery source dumped into the XML. That would seem to require a CDATA wrapper to work. If you can use script tags please do that so we can eliminate that variable.

If you take your XUL app that includes jquery-1.7.2 via a script tag, and edit that script tag to use jquery-git instead, does it work? If not, what is the error message you receive?

Changed August 28, 2012 04:06AM UTC by brandon@1942design.com comment:13

status: pendingnew

using the following example is the only way to get to the root of the issue, if you update your main.xul and then run the .exe in the root of that folder structure, you will also be able to see the errors :


<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="DigiNow Jukebox" width="900" height="700" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script>
	window.onerror=function(e){
 alert(e)
}
	</script>
	
	<script>
		<![CDATA[
		
		/*! jQuery v@whatever you want jquery.com | jquery.org/license */

blah blah blah jquery mumbo jumbo magic stuff here ....


]]>
	</script>
	
	<script>
alert($);
	</script>
	
</window>

Using the jQuery-git I still get the d is undefined

Changed August 28, 2012 12:01PM UTC by dmethvin comment:14

status: newpending

Include the script by reference as I requested, not by copy-pasta. Does that work?

Changed August 28, 2012 02:01PM UTC by brandon@1942design.com comment:15

status: pendingnew

No. It fails silently. As stated, the above method will be the way to debug this. The error is that d is undefined.

Changed August 28, 2012 07:29PM UTC by brandon@1942design.com comment:16

the jquery-git provides the error a is undefined now

Changed September 08, 2012 05:39PM UTC by mikesherov comment:17

status: newpending

Can you use an unminified copy of the source and provide us with the line number and text of the error?

Changed September 08, 2012 06:16PM UTC by brandon@1942design.com comment:18

status: pendingnew

That is what I have been doing. I unfortunately do not know the line number. As I debug the code and declare the various variables, the error trail moves onto the next variable. It seems there is either a scoping issue which does not conform to strict javascript rules, or not all variables are declared according to strict javascript rules.

I have provided a link of everything needed to do so on a windows machine here:

http://uploadbin.net/502d8a88ebc311e1baaad1d1a5c7f576/Digi+Now+Jukebox.rar

once installed, in the folder structure you will find chrome/main.xul

you can modify it like this to have a start to begin debugging from.

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="DigiNow Jukebox" width="900" height="700" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script>
	window.onerror=function(e){
 alert(e)
}
	</script>
	
	<script>
		<![CDATA[
		
		/*! jQuery v@whatever you want jquery.com | jquery.org/license */

non minified jQuery here

]]>
	</script>
	
	<script>
alert($);
	</script>
	
</window>

Changed September 08, 2012 06:26PM UTC by dmethvin comment:19

resolution: → notabug
status: newclosed

Sorry, we are just not getting any other reports so I have to think this is an issue with the way you're building your application. We're not experts on that and don't have the time to become experts on it. Find an expert on a forum somewhere, ask them what is going on, and report back if there are any things that jQuery can do to help.

Changed September 26, 2012 08:01PM UTC by pint.glass comment:20

Replying to [comment:16 brandon@…]:

the jquery-git provides the error a is undefined now

a is undefined because of --

1) https://github.com/jquery/jquery/commit/dc83072878ed9636c8158a014bd9fa4acc1ccce3

2) [Tangentially] https://github.com/jquery/jquery/commit/c79a533ffd3e063a498fde6bdb1b934c7b4b47ab

Something like the following in support.js might avoid that error --

	// Preliminary tests
	div.setAttribute( "className", "t" );
	div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";

	all = div.getElementsByTagName("*");
	a = div.getElementsByTagName("a")[ 0 ];

	// Can't get basic test support
	if ( !all || !all.length || !a) {
		return {};
	}

	a.style.cssText = "top:1px;float:left;opacity:.5";

Not sure what it would do for any other errors.

Changed September 26, 2012 08:53PM UTC by gibson042 comment:21

component: unfiledsupport
milestone: None1.next
resolution: notabug
status: closedreopened

Changed September 26, 2012 09:03PM UTC by gibson042 comment:22

owner: brandon@1942design.comgibson042
status: reopenedassigned

Changed October 01, 2012 12:57AM UTC by Richard Gibson comment:23

resolution: → fixed
status: assignedclosed

Fix #12357: be more kind to non-browser environments. Close gh-938.

Changeset: 22fac5c2e40b00911933040afaf9adcdd2c00ac2

Changed October 01, 2012 04:43PM UTC by dmethvin comment:24

milestone: 1.next1.8.3

Changed October 01, 2012 04:43PM UTC by dmethvin comment:25

priority: undecidedlow

Changed October 01, 2012 04:44PM UTC by dmethvin comment:26

@pint.glass, can you test with jquery-git and see if this problem is resolved?

Changed October 21, 2012 12:51AM UTC by gibson042 comment:27

#12774 is a duplicate of this ticket.