Bug #75562 [NEW]: token_get_all() errors should be catchable

From: Date: Thu, 23 Nov 2017 15:58:44 +0000
Subject: Bug #75562 [NEW]: token_get_all() errors should be catchable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212699@lists.php.net to get a copy of this message
From:             software at nano dot net dot tr
Operating system: Ubuntu 16.04.3 LTS
PHP version:      7.1.11
Package:          Reproducible crash
Bug Type:         Bug
Bug description:token_get_all() errors should be catchable

Description:
------------
OS is Ubuntu 16.04.3 LTS
PHP package is 7.1.11-1+ubuntu16.04.1+deb.sury.org+1 installed from
http://ppa.launchpad.net/ondrej/php/ubuntu

While using token_get_all() with TOKEN_PARSE flag; if tested code block
has syntax error, then process killed with "Parse error: syntax error".
Example: https://3v4l.org/05lUI




Test script:
---------------
<?php
// Syntax error: tested code has a space between equal signs
$tokens=token_get_all('<?php if($foo= =$bar) {}', TOKEN_PARSE);
var_dump($tokens); // not printed on error

Expected result:
----------------
function returns (FALSE) or throws a catchable error. script continues
to run. error could be checked/catched with if, try-catch or error
handler.

Actual result:
--------------
script dies with error: (Parse error: syntax error, unexpected '=' in 
on line 1)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=75562&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=75562&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=75562&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=75562&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=75562&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=75562&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=75562&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=75562&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=75562&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=75562&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=75562&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=75562&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=75562&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=75562&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75562&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=75562&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=75562&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=75562&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75562&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=75562&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=75562&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#212699) next »