Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP file that aggregates javascript files is adding unprintable characters

I am trying to install phpMyAdmin on our debian server. I have tried downloading it directly through wget, downloading to my Mac and then uploading through FTP, both times I get the same error...

When I try to load the page in the web browser (Safari, Chrome, or IE 9) I get a blank white screen and a error in the Inspector (or console depending on the browser).

SyntaxError: Invalid character '\u0031' get_scripts.js.php:19111

After that I get several javascript errors related the fact that the javascript files aren't loading. I have seen this error once before, and the problem was due to incorrect line endings.. I have tried installing this a few different ways.. so I can't see that contenting to be a problem.. If this had the wrong line endings for a linux box, I can't see me being the first one to post about it.

Any ideas?

Update: We have done a LOT of testing.. the get_scripts.js.php file aggregates the js files given to it through the query string into a single document. There are about 12 unprintable characters being generated at the end of the file... after the output of the get_scripts.js.php file. When we cut headers out of the output, there are fewer chars, but still 1.

Here's where it gets weird. When I comment out the read file() function (that is outputting the javascript) the characters stay, when I cut the new lines that separate the js files, the characters stay. When I cut both, they go away.

I have a feeling this is web server, PHP or file system related, but its not happening on any of the other pages on the host....

Any ideas now?

like image 510
whiteatom Avatar asked Feb 07 '14 00:02

whiteatom


1 Answers

I've seen this once before, it was an issue with how the web server is reading the file's mime type on the system versus how the client browser is accepting it.

For example, if /etc/mime.types lists js files as "application/javascript" and you are sending headers for "text/x-javascript" there will be binary conversion issue and as a result odd characters will appear in your files.

Try changing /etc/mime.types to include (or replace) javascript as text/x-javascript. If that work doesn't try adding the apache types as well.

like image 183
user3282181 Avatar answered Nov 08 '22 09:11

user3282181