php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60096 token_get_all on b"$var" returns invalid string token
Submitted: 2011-10-19 16:02 UTC Modified: 2011-11-02 12:34 UTC
From: nikic@php.net Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.4.0beta1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikic@php.net
New email:
PHP Version: OS:

 

 [2011-10-19 16:02 UTC] nikic@php.net
Description:
------------
token_get_all('<?php b"$var"') will return 'b"' as a string-token, even though it is not a single character.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-19 22:55 UTC] felipe@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

Currently it's expected, as the 'b' prefix doesn't produces a separated token.
 [2011-10-19 22:55 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-10-20 05:19 UTC] nikic@php.net
I doubt that this is expected. Only single characters can be represented using a one-char string token, because the token number and token text are identical in this case.
'b"' is not a single character and thus can't be returned as a string token, because the token number is chr('"'), not chr('b"') (which is chr('b')).
 [2011-10-28 18:39 UTC] nikic@php.net
-Status: Bogus +Status: Open
 [2011-11-02 12:34 UTC] johannes@php.net
This is defined in the scanner this way.
Currently we don't need the b prefix and have it for forward compatibility only. I doubt we won't add an extra token for the 'b' prefix (which most likely creates conflicts)
If anything like this is done it should be done according to the needs of a future use of that prefix.
 [2011-11-02 12:34 UTC] johannes@php.net
-Status: Open +Status: Wont fix
 [2011-11-02 15:11 UTC] nikic@php.net
@johannes: My main issue here is that the output of token_get_all is malformed. 'b"' isn't a valid string token, because it has more than one character.

But really, I have to admit that I can't think of a way how to cleanly solve this issue, without breaking BC for the tokenizer ext. So I'd say I agree with the Wontfix, especially as this is easy to detect and fix in userland code.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 07:01:32 2024 UTC