BOM in a PHP page auto generated by Wordpress

2020-02-15 10:40发布

I admin two different blogs. They are both wordpress 2.8.6 (so they have exactly the same source code, plugins apart) but they are located on two different hosting platform (hostmonster.com and aruba.it). To explain my problem I've dumped with SmartSniff a session with each one of the sites.

Here is the dump from hostmonster:

GET /blog/paolo/ HTTP/1.1
Host: www.e-venturi.com
Accept-Encoding: identity
Accept-Language: en-us
Accept: text/html, text/plain, text/xml, image/gif, image/x-xbitmap, image/x-icon,image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;)


HTTP/1.1 200 OK
Date: Sat, 28 Nov 2009 23:47:38 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.11
X-Pingback: http://www.e-venturi.com/blog/paolo/xmlrpc.php
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

a6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

and now from aruba:

GET /blog/ HTTP/1.1
Host: www.cubanite.net
Accept-Encoding: identity
Accept-Language: en-us
Accept: text/html, text/plain, text/xml, image/gif, image/x-xbitmap, image/x-icon,image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;)


HTTP/1.1 200 OK
Date: Sat, 28 Nov 2009 23:49:19 GMT
Server: Apache/2.2
X-Pingback: http://www.cubanite.net/blog/xmlrpc.php
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

100b
...<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

(note: a6 and 100b are the packet size reported by SmartSniff)

Ok, the big difference are the three dots in front of the <!DOCTYPE in aruba. They are the UTF-8 BOM (0xef 0xbb 0xbf).

Being the same PHP source on both the servers, why does it appears only on one server ?

The content is generated so the post author can't deliberately insert a BOM and I've verified the template to be BOM free too. Naturally there are different PHP and Apache versions on the servers... what can I check or set to diagnose and resolve the problem ? By the way I don't want the BOM.

Many thanks in advance.

1条回答
做个烂人
2楼-- · 2020-02-15 11:06

The BOM is in one of the PHP source files before the opening <?php. Occasionally, this can pop up because you viewed the source in a poorly written text editor, used an FTP client with a bug, used an unzip tool that automatically threw in the BOM, got the source code from a shady mirror, etc. etc.

My solution is to open up the primary WP files (index.php, wp-*.php, etc.) in Notepad++ and switch the format from Windows/Mac to Unix and turn off the BOM. This will clean up the files of any source issues.

The reason you're seeing it differently on two different servers could be because the servers are running two different server applications or two different operating systems (or even having two different configurations). The platform disparities would lead to your servers sending out their own unique interpretation of the BOM.

Hope this helps!

查看更多
登录 后发表回答