• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed unrecognized expression error in xenforo.js

#1
Goto this url:
http://xenforo.com/community/forums/bugs/#/xyz/0
=>
Uncaught Error: Syntax error, unrecognized expression: #/xyz/0

This error is throw in xenforo.js:

Code:
$(window).on('load', function() {
    if (isScrolled || !window.location.hash)
    {
        return;
    }
    var hash = window.location.hash.replace(/[:.#\s\[\]]/g, ''),
        $match = $('#' + hash); //error here
    if ($match.length)
    {
         $match.get(0).scrollIntoView(true);
    }
});
I know this error is harmless. But it's better to be fixed.

Of course this error will be thrown if we add a hash like #/xyz/0 to every forum url (in my custom route prefix too)
 

Mike

XenForo developer
Staff member
#2
Fixed - I changed from trying to strip invalid characters to whitelisting alphanumeric, underscore and dash.