Bug #69092 [NEW]: Declare Encoding Compile Check Wrong
From: ircmaxell
Operating system: All
PHP version: master-Git-2015-02-20 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Declare Encoding Compile Check Wrong
Description:
------------
The current compile-time error check for declare(encoding="...") is
incorrect.
Declare is a parse-time only directive, which does not respect scope.
The current compile-time checks for the declare(encoding) directive only
check to see if it's the first opcode in the active oparray.
This is fine if the active oparray is a file, however if it is a
function odd behavior will be allowed. In the provided test script,
"Bye" would be interpreted using the UTF-8 encoding pragma, where "Hi"
would use the default.
Test script:
---------------
<?php
echo "Hi";
function foo() {
declare(encoding="UTF-8");
}
echo "Bye";
Expected result:
----------------
Fatal error: Encoding declaration pragma must be the very first
statement in the script
Actual result:
--------------
HiBye
--
Edit bug report at https://bugs.php.net/bug.php?id=69092&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69092&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69092&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69092&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69092&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69092&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69092&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69092&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69092&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69092&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69092&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69092&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69092&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69092&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69092&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69092&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69092&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69092&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69092&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69092&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69092&r=mysqlcfg
Thread (3 messages)
- ircmaxell@php.net