Bug #69092 [Opn->Csd]: Declare Encoding Compile Check Wrong

From: Date: Sun, 22 Feb 2015 03:01:00 +0000
Subject: Bug #69092 [Opn->Csd]: Declare Encoding Compile Check Wrong
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190877@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69092&edit=1

 ID:                 69092
 Updated by:         laruence@php.net
 Reported by:        ircmaxell@php.net
 Summary:            Declare Encoding Compile Check Wrong
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   All
 PHP Version:        master-Git-2015-02-20 (Git)
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2015-02-20 16:45:18] ircmaxell@php.net

Patched implementation for 7:

https://github.com/php/php-src/pull/1107

------------------------------------------------------------------------
[2015-02-20 15:34:29] ircmaxell@php.net

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 this bug report at https://bugs.php.net/bug.php?id=69092&edit=1


Thread (3 messages)

« previous php.bugs (#190877) next »