Square [] or curly {} brackets in rel attribute cause Uncaught exception

382 views
Skip to first unread message

RavanH

unread,
Aug 14, 2011, 11:42:07 AM8/14/11
to fancybox
FancyBox 1.3.4 in conjunction with jQuery 1.6.1, when using
rel="square[brackets]" (for example, anything with [ and ] really) on
links other than normal image image content type like swf, html or
iframe content, cause the following Uncaught exception error.

Uncaught exception: Syntax error, unrecognized expression:
[rel=square[brackets]]

Error thrown at line 17, column 23918 in <anonymous function:
k.error>(a) in http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
throw"Syntax error, unrecognized expression: "+a
called from line 17, column 23281 in <anonymous function: k.filter>(a,
c, d, e) in http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
k.error(a);
called from line 17, column 19667 in <anonymous function>(b, d, f, g)
in http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
q=g?
{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||
x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?
k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;
called from line 17, column 42832 in <anonymous function: k>(b, e, f,
g) in http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
return a(b,e,f,g)
called from line 17, column 47555 in <anonymous function: find>(a) in
http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
g=e.length,f.find(a,this[c],e);
called from line 16, column 15667 in <anonymous function: init>(a, d,
f) in http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)
called from line 16, column 13598 in <anonymous function>(a, b) in
http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
return new e.fn.init(a,b,h)
called from line 37, column 472 in <anonymous function:
b.fn.fancybox>(c) in
http://demo.4visions.nl/wp-content/plugins/easy-fancybox/fancybox/jquery.fancybox-1.3.4.pack.js?ver=1.3.4:
o=b("a[rel="+c+"], area[rel="+c+"]");
called from line 17, column 1708 in <anonymous function: handle>(c) in
http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
var k=j.handler.apply(this,g);
called via Function.prototype.apply() from line 16, column 60224 in
<anonymous function: k>(a) in http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?
f.event.handle.apply(k.elem,arguments):b



When using only the opening square bracket [ or with jQuery 1.4, the
error changes to

Uncaught exception: TypeError: Cannot convert 'a' to object
...

An live example can be seen on http://demo.4visions.nl/easy-fancybox-sandbox/escaping-youtube/

Is this a bug in FancyBox or jQuery or...?

RavanH

unread,
Aug 14, 2011, 11:44:37 AM8/14/11
to fancybox
Sorry, the title is wrong: curlies cause no error... Just the square
ones.


On 14 aug, 17:42, RavanH <ravanha...@gmail.com> wrote:
> FancyBox 1.3.4 in conjunction with jQuery 1.6.1, when using
> rel="square[brackets]" (for example, anything with [ and ] really) on
> links other than normal image image content type like swf, html or
> iframe content, cause the following Uncaught exception error.
>
> Uncaught exception: Syntax error, unrecognized expression:
> [rel=square[brackets]]
>
> Error thrown at line 17, column 23918 in <anonymous function:
> k.error>(a) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     throw"Syntax error, unrecognized expression: "+a
> called from line 17, column 23281 in <anonymous function: k.filter>(a,
> c, d, e) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     k.error(a);
> called from line 17, column 19667 in <anonymous function>(b, d, f, g)
> inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     q=g?
> {expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||
> x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?
> k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;
> called from line 17, column 42832 in <anonymous function: k>(b, e, f,
> g) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return a(b,e,f,g)
> called from line 17, column 47555 in <anonymous function: find>(a) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     g=e.length,f.find(a,this[c],e);
> called from line 16, column 15667 in <anonymous function: init>(a, d,
> f) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)
> called from line 16, column 13598 in <anonymous function>(a, b) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return new e.fn.init(a,b,h)
> called from line 37, column 472 in <anonymous function:
> b.fn.fancybox>(c) inhttp://demo.4visions.nl/wp-content/plugins/easy-fancybox/fancybox/jqu...
>     o=b("a[rel="+c+"], area[rel="+c+"]");
> called from line 17, column 1708 in <anonymous function: handle>(c) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     var k=j.handler.apply(this,g);
> called via Function.prototype.apply() from line 16, column 60224 in
> <anonymous function: k>(a) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?
> f.event.handle.apply(k.elem,arguments):b
>
> When using only the opening square bracket [ or with jQuery 1.4, the
> error changes to
>
> Uncaught exception: TypeError: Cannot convert 'a' to object
> ...
>
> An live example can be seen onhttp://demo.4visions.nl/easy-fancybox-sandbox/escaping-youtube/

RavanH

unread,
Aug 15, 2011, 8:14:31 AM8/15/11
to fancybox
Replying to myself here but found a fix:


On line 37 in jquery.fancybox-1.3.4.pack.js there is the part

else{o=b("a[rel="+c+"], area[rel="+c+"]")

the variable c needs to be escaped with single quotes to prevent
square brackets messing it up:

else{o=b("a[rel='"+c+"'], area[rel='"+c+"']")

Note the single quotes after rel= and before the closing ]

My test page on http://demo.4visions.nl/easy-fancybox-sandbox/escaping-youtube/
is using this patched js now...


The patched part in the packed js corresponds with line 815 in
jquery.fancybox-1.3.4.js:

selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");

which should be (I suppose, but not tested)

selectedArray = $("a[rel='" + rel + "'], area[rel='" + rel + "']");


Hope this (or something to the same effect) makes it into the next
release :)



On 14 aug, 17:42, RavanH <ravanha...@gmail.com> wrote:
> FancyBox 1.3.4 in conjunction with jQuery 1.6.1, when using
> rel="square[brackets]" (for example, anything with [ and ] really) on
> links other than normal image image content type like swf, html or
> iframe content, cause the following Uncaught exception error.
>
> Uncaught exception: Syntax error, unrecognized expression:
> [rel=square[brackets]]
>
> Error thrown at line 17, column 23918 in <anonymous function:
> k.error>(a) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     throw"Syntax error, unrecognized expression: "+a
> called from line 17, column 23281 in <anonymous function: k.filter>(a,
> c, d, e) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     k.error(a);
> called from line 17, column 19667 in <anonymous function>(b, d, f, g)
> inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     q=g?
> {expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||
> x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?
> k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;
> called from line 17, column 42832 in <anonymous function: k>(b, e, f,
> g) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return a(b,e,f,g)
> called from line 17, column 47555 in <anonymous function: find>(a) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     g=e.length,f.find(a,this[c],e);
> called from line 16, column 15667 in <anonymous function: init>(a, d,
> f) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)
> called from line 16, column 13598 in <anonymous function>(a, b) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return new e.fn.init(a,b,h)
> called from line 37, column 472 in <anonymous function:
> b.fn.fancybox>(c) inhttp://demo.4visions.nl/wp-content/plugins/easy-fancybox/fancybox/jqu...
>     o=b("a[rel="+c+"], area[rel="+c+"]");
> called from line 17, column 1708 in <anonymous function: handle>(c) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     var k=j.handler.apply(this,g);
> called via Function.prototype.apply() from line 16, column 60224 in
> <anonymous function: k>(a) inhttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:
>     return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?
> f.event.handle.apply(k.elem,arguments):b
>
> When using only the opening square bracket [ or with jQuery 1.4, the
> error changes to
>
> Uncaught exception: TypeError: Cannot convert 'a' to object
> ...
>
> An live example can be seen onhttp://demo.4visions.nl/easy-fancybox-sandbox/escaping-youtube/

RavanH

unread,
Aug 15, 2011, 8:52:35 AM8/15/11
to fancybox
Or maybe more consistent with jQuery markup as discussed on
http://api.jquery.com/category/selectors/ :

selectedArray = $('a[rel="' + rel + '"], area[rel="' + rel + '"]');

;)


On 15 aug, 14:14, RavanH <ravanha...@gmail.com> wrote:
> Replying to myself here but found a fix:
>
> On line 37 in jquery.fancybox-1.3.4.pack.js there is the part
>
> else{o=b("a[rel="+c+"], area[rel="+c+"]")
>
> the variable c needs to be escaped with single quotes to prevent
> square brackets messing it up:
>
> else{o=b("a[rel='"+c+"'], area[rel='"+c+"']")
>
> Note the single quotes after rel= and before the closing ]
>
> My test page onhttp://demo.4visions.nl/easy-fancybox-sandbox/escaping-youtube/

JFK

unread,
Aug 15, 2011, 1:33:46 PM8/15/11
to fancybox
interesting. I see this more happening in a wordpress scenario than
elsewhere due to the weird invalid markup they just to have ;o)

On Aug 15, 5:52 am, RavanH <ravanha...@gmail.com> wrote:
> Or maybe more consistent with jQuery markup as discussed onhttp://api.jquery.com/category/selectors/:

Zach Ba

unread,
Jul 7, 2014, 9:19:56 PM7/7/14
to fanc...@googlegroups.com
I am having an issue trying to use fancybox with lighthouse, is there some one here who can try to lend a hand?
Reply all
Reply to author
Forward
0 new messages