php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72556 php using .xml file as source tries to execute header
Submitted: 2016-07-06 19:11 UTC Modified: 2016-07-10 15:08 UTC
From: jim dot michaels at Jesusnjim dot com Assigned: cmb (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0Git-2016-07-06 (snap) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jim dot michaels at Jesusnjim dot com
New email:
PHP Version: OS:

 

 [2016-07-06 19:11 UTC] jim dot michaels at Jesusnjim dot com
Description:
------------
1. 7.1Git-2016-07-06 isn't even on your site - no dir for it.
2. php using .xml file as source tries to execute XML header because of <? and ?> but xml header says <?xml version='1.0' encoding='UTF-8'?>

don't blast me because they are not separate bugs please. you know what happens if too many are put in on the same day.

Test script:
---------------
<?xml version='1.0' encoding='UTF-8'?>

Expected result:
----------------
<?xml should be differentiated from <?php. in fact, it might be a lex priority issue where <? is lexed before <?php but XML and XHTML are not detected properly due to same problem. what is the header for XHTML 1.1/1.0? what about XHTML5? XHTML5.1? 5.2? see whatwg.org

php should completely ignore the xml file since there is no PHP in it. or so I had thought. and it's not just a simple .xml file extension detection, it's an ENBF change, yes?

Actual result:
--------------
Wed 07/06/2016 11:49:00.42|C:\w\Jesusnjim|>php menu7a.xml

Parse error: syntax error, unexpected 'version' (T_STRING) in C:\w\Jesusnjim\menu7a.xml on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-06 20:08 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-07-06 20:08 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

> 7.1Git-2016-07-06 isn't even on your site - no dir for it.

php.net does not package Git snapshots, as you can easily get them
yourself, see <http://php.net/git.php>.

> php using .xml file as source tries to execute XML header
> because of <? and ?> but xml header says <?xml version='1.0'
> encoding='UTF-8'?>

If you don't like that behavior, just disable short_open_tag, see
<http://php.net/manual/en/ini.core.php#ini.short-open-tag>.
 [2016-07-09 23:49 UTC] jim dot michaels at Jesusnjim dot com
you blasted me. I asked you not to. too many bugs to handle? do you need prayer or something?
try 2 hours rest on your bed and see if things get better real fast, thinking about nothing in particular.
I forgive.

the problem here is in the EBNF and the way it detects those short tags. I had thought short-tags was deprecated or dropped from what I remember. 
try parsing these in order:
<?xml - ignore
<?php - process as PHP
<? - process as PHP
if you do short tags first, <?php will never see light of day for proper detection.
 [2016-07-10 15:08 UTC] cmb@php.net
> I had thought short-tags was deprecated or dropped from what I
> remember.

No need for guessing, just read the docs[1]. :) If you wish that
short_open_tag will be deprecated and eventually completely
removed, please re-open and change this ticket to feature request.

[1] <http://php.net/manual/en/ini.core.php#ini.short-open-tag>
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 20:01:35 2025 UTC