Bug Tracker

Modify

Ticket #12357 (closed bug: fixed)

Opened 20 months ago

Last modified 18 months ago

jQuery 1.8.0 Not parseable by XUL Runner Applications

Reported by: brandon@… Owned by: gibson042
Priority: low Milestone: 1.8.3
Component: support Version: 1.8.0
Keywords: Cc:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 20 months ago by dmethvin

  • Owner set to brandon@…
  • Status changed from new to pending

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.

comment:2 Changed 20 months ago by dmethvin

  • Status changed from pending to closed
  • Resolution set to duplicate

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

comment:3 Changed 20 months ago by Brandon Nosaki Miller

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.

comment:4 Changed 20 months ago by dmethvin

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.

comment:5 Changed 20 months ago by anonymous

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

comment:6 Changed 20 months ago by Brandon Nozaki Miller

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

comment:7 Changed 20 months ago by dmethvin

@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!

comment:8 Changed 20 months ago by anonymous

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 /[<|>]/

comment:9 Changed 20 months ago by dmethvin

  • Status changed from closed to reopened
  • Resolution duplicate deleted

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.

comment:10 Changed 20 months ago by dmethvin

  • Status changed from reopened to pending

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 ...

comment:11 Changed 20 months ago by brandon@…

  • Status changed from pending to new

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.

comment:12 Changed 20 months ago by dmethvin

  • Status changed from new to pending

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?

comment:13 Changed 20 months ago by brandon@…

  • Status changed from pending to new

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

comment:14 Changed 20 months ago by dmethvin

  • Status changed from new to pending

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

comment:15 Changed 20 months ago by brandon@…

  • Status changed from pending to new

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

comment:16 follow-up: ↓ 20 Changed 20 months ago by brandon@…

the jquery-git provides the error a is undefined now

comment:17 Changed 20 months ago by mikesherov

  • Status changed from new to pending

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

comment:18 Changed 20 months ago by brandon@…

  • Status changed from pending to new

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>

comment:19 Changed 20 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to notabug

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.

comment:20 in reply to: ↑ 16 Changed 19 months ago by pint.glass

Replying to 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.

comment:21 Changed 19 months ago by gibson042

  • Status changed from closed to reopened
  • Resolution notabug deleted
  • Component changed from unfiled to support
  • Milestone changed from None to 1.next

comment:22 Changed 19 months ago by gibson042

  • Owner changed from brandon@… to gibson042
  • Status changed from reopened to assigned

comment:23 Changed 19 months ago by Richard Gibson

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 22fac5c2e40b00911933040afaf9adcdd2c00ac2

comment:24 Changed 19 months ago by dmethvin

  • Milestone changed from 1.next to 1.8.3

comment:25 Changed 19 months ago by dmethvin

  • Priority changed from undecided to low

comment:26 Changed 19 months ago by dmethvin

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

comment:27 Changed 18 months ago by gibson042

#12774 is a duplicate of this ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.