-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1617 from sjinks/view-superglobals
Do not allow to override superglobals in views
- Loading branch information
Showing
8 changed files
with
160 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2013 Phalcon Team (http://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file docs/LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Andres Gutierrez <[email protected]> | | ||
| Eduar Carvajal <[email protected]> | | ||
| Vladimir Kolesnikov <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
#include "mvc/view/engine/helpers.h" | ||
#include <Zend/zend_globals.h> | ||
|
||
zend_bool phalcon_mvc_view_engine_php_symtable_merger(HashTable *ht, void *pData, zend_hash_key *hash_key, void *pParam) | ||
{ | ||
#ifdef ZTS | ||
TSRMLS_FETCH_FROM_CTX(pParam); | ||
#endif | ||
|
||
return hash_key->arKey && hash_key->nKeyLength && !zend_hash_quick_exists(CG(auto_globals), hash_key->arKey, hash_key->nKeyLength, hash_key->h); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2013 Phalcon Team (http://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file docs/LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Andres Gutierrez <[email protected]> | | ||
| Eduar Carvajal <[email protected]> | | ||
| Vladimir Kolesnikov <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
#ifndef PHALCON_MVC_VIEW_ENGINE_HELPERS_H | ||
#define PHALCON_MVC_VIEW_ENGINE_HELPERS_H | ||
|
||
#include <Zend/zend.h> | ||
|
||
zend_bool phalcon_mvc_view_engine_php_symtable_merger(HashTable *ht, void *pData, zend_hash_key *hash_key, void *pParam); | ||
|
||
#endif /* PHALCON_MBC_VIEW_ENGINE_HELPERS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--TEST-- | ||
Do not allow to override superglobals in views - https://github.com/phalcon/cphalcon/pull/1617 | ||
--SKIPIF-- | ||
<?php include('skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
$di = new \Phalcon\DI\FactoryDefault(); | ||
$view = new \Phalcon\Mvc\View(); | ||
$engine = new \Phalcon\Mvc\View\Engine\Php($view, $di); | ||
|
||
foreach (array('_GET', '_POST', '_COOKIE', 'GLOBALS') as $v) { | ||
$view->setVar($v, strtolower($v)); | ||
} | ||
|
||
var_dump($view->getParamsToView()); | ||
var_dump($engine->render(__DIR__ . '/views/superglobals.phtml', $view->getParamsToView(), false)); | ||
?> | ||
--EXPECT-- | ||
array(4) { | ||
["_GET"]=> | ||
string(4) "_get" | ||
["_POST"]=> | ||
string(5) "_post" | ||
["_COOKIE"]=> | ||
string(7) "_cookie" | ||
["GLOBALS"]=> | ||
string(7) "globals" | ||
} | ||
array | ||
array | ||
array | ||
array | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
echo gettype($_GET), PHP_EOL; | ||
echo gettype($_POST), PHP_EOL; | ||
echo gettype($_COOKIE), PHP_EOL; | ||
echo gettype($GLOBALS), PHP_EOL; |