Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal Characters appended to javascript file

I think my apache webserver has got problem. I can't reference jquery.js

I get the following errors:

With chrome:

Uncaught SyntaxError: Unexpected token ILLEGAL

With firefox:

Error: illegal character
Source File: http://xxxxxxxxx/test/javascript/jquery.js
Line: 1
Source Code:
�Hz�ÚH[9�R

Below is my test html code

<html>
<head>
    <script type="text/javascript" src="javascript/jquery.js"></script>
    <script type="text/javascript">
        function doclick(){
            jQuery('#hello').attr('value', "mmmmef")
        }
    </script>
</head>
<body>
    <input type="button" name="hello" id="hello" value="hello" onclick="doclick();" />
</body>
</html>

It is not only happening to jquery.js, these illegal characters are being appended to all js and css files.

I login with ssh and view these js and css files with vi command, but there are none of these characters. But when I try to download or view/edit with FTP clients Filezilla or CuteFTP, these illegal characters are included.

What's wrong with my server? The same code can run in my local windows server and another centos server.

like image 629
zawmn83 Avatar asked Mar 12 '12 11:03

zawmn83


People also ask

How do you fix an illegal character?

The “illegal character” error occurs in the compilation phase, so it's quite easy to detect. The next example shows us how it works. Ideally, to fix this problem, the only thing to do is save the file as UTF-8 without BOM encoding. After that, the problem is solved.

What are the illegal characters in path?

The "Illegal characters" exception means that the file path string you are passing to ReadXml is wrong: it is not a valid path. It may contain '?' , or ':' in the wrong place, or '*' for example. You need to look at the value, check what it is, and work out where the illegal character(s) are coming from.

Is an example of an illegal character?

Illegal characters in English are typically punctuation marks or letters that include unusual accent marks. Question marks are commonly illegal characters for naming computer files or folders.

What does illegal character mean?

The JavaScript exception "illegal character" occurs when there is an invalid or unexpected token that doesn't belong at this position in the code.


1 Answers

I found the solution at

http://www.cyberciti.biz/tips/apache-223-corrupt-file-download-issue.html

Just open httpd.conf and put below lines

            EnableMMAP off
            EnableSendfile off

then

            # /sbin/service httpd restart
like image 145
zawmn83 Avatar answered Oct 21 '22 05:10

zawmn83