Page MenuHomePhabricator

javascript syntax error
Closed, InvalidPublic

Description

Author: ewald.lieuwes

Description:
Source file: /index.php?title=&action=raw&gen=js

second error:
The stylesheet /index.php?title=&action=raw&gen=css was not loaded because its
MIME type, "text/html", is not "text/css"

(Source of those errors is the Firefox Javascript Console, but also in Internet
Explorer this javascript error occurs.)

Changing MIME type doesn't do any good, so doesn't changing Content-Type,
changing language (i use dutch) or the character-encoding to UTF8

The function is located in the SkinPHPTal.php file and looks like this:
if($this->loggedin) {
$tpl->set( "jsvarurl", $this->makeUrl('-','action=raw&gen=js&smaxage=0') );
} else {
$tpl->set( "jsvarurl", $this->makeUrl('-','action=raw&gen=js') );
}

Those errors only occurs with not-logged in users, when logged in, no javascript
errors.


Version: 1.3.x
Severity: normal

Details

Reference
bz497

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 6:57 PM
bzimport set Reference to bz497.
bzimport added a subscriber: Unknown Object (MLST).

Mine comes back with this header:
Content-Type: text/javascript; charset=utf-8

Can you confirm that the header is wrong (for instance using the Live HTTP Headers extension)? If so, check for PHP error messages interrupting
output or other problems.

ewald.lieuwes wrote:

The Content-Type:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

This doesn't seem wrong to me, nl.wikipedia.org got the exact same and here no
errors. I can't put up a link to my mediawiki here because its on a intranet.

(In reply to comment #1)

Mine comes back with this header:
Content-Type: text/javascript; charset=utf-8

Can you confirm that the header is wrong (for instance using the Live HTTP

Headers extension)? If so, check for PHP error messages interrupting

output or other problems.

*ping*

Ewald, are you still experiencing this problem? You need to check the content
type of the *CSS* URL, not the web page. The most likely cause of the wrong
content type header being sent is either an error message being shown or too
much whitespace at the beginning or end of a PHP source file causing PHP to
begin outputting text before the headers are set.

adam wrote:

Hey all, I have the same version of MediaWiki installed as Ewald and I'm having the same problem. It happens for
me when I set the wgWhitelistread variable. When a user thats not logged in hits a page thats not in the white
list it gives the same errors as ewald. Once you login and you go to the same page, you don't get the errors.
Here is the error out of the javascript console on mozilla:

Error: syntax error
Source File: /index.php?title=-&action=raw&gen=js
Line: 1
Source Code:
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">

ewald.lieuwes wrote:

the problem seems to be "fixed": i just deleted the line "<script
type="text/javascript" tal:attributes="src jsvarurl"></script>" from the
xhtml_slim.pt file in the templates folder. The javascript error is gone,
probably something else is broken now but i have no clue what this line does.
So, not really fixed, but the error is gone.

adam wrote:

I looked at the headers with LiveHTTPHeaders, and I saw that they are definately wrong for users
that aren't logged in. for the /index.php?title=-&action=raw&gen=js script, the headers that
content type is Content-Type: text/html; charset=utf-8, which should be text/javascript. When the
users are logged in, it uses the /index.php?title=-&action=raw&gen=js&smaxage=0 url to load the
script and the content type is Content-Type: text/javascript; charset=utf-8. I think part of the
problem is that when your not logged in, /index.php?title=-&action=raw&gen=js doesn't actually
retrieve a js file, it pulls back the html page your on. When you are logged in and you type
in /index.php?title=-&action=raw&gen=js&smaxage=0 it pulls back a js file. Any one got any ideas?

If you add '-' to the whitelist, does that work? If not that, how about 'MediaWiki:Monobook.js'?

adam wrote:

Thank you!! Adding the "-" to the whitelist worked perfect. I also had to
add "MediaWiki:Monobook.css" to the whitelist to remove the css error. Just "-"
should have worked like it did for the javascript, maybe it was a cache problem.
I'm not sure if this is the same as Ewald's problem or not. The reason why I had
the problem is because the only page I had in the wgWhitelistRead variable was the
login page.

(In reply to comment #7)

If you add '-' to the whitelist, does that work? If not that, how

about 'MediaWiki:Monobook.js'?