Skip to content

Commit

Permalink
Removed HTTPRequest->parse_str_callback(). HTTPRequest::parse_str is …
Browse files Browse the repository at this point in the history
…static method.
  • Loading branch information
kakserpom committed Dec 2, 2010
1 parent a517e44 commit 1809a9c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
5 changes: 1 addition & 4 deletions app-examples/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ class ExampleRequest extends HTTPRequest {
public function run() {
$stime = microtime(TRUE);
$this->header('Content-Type: text/html; charset=utf-8');

var_dump(is_uploaded_file(
$_FILES['myfile']['tmp_name']
));

$this->registerShutdownFunction(function() {
?></html><?php
});
Expand Down
Empty file modified bin/php-chroot
100755 → 100644
Empty file.
Empty file modified bin/phpdaemon
100755 → 100644
Empty file.
8 changes: 4 additions & 4 deletions conf/conf.d/example.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Example of included file
# Example of included file



Empty file modified doc/gendoc
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion lib/Daemon_Config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Daemon_Config implements ArrayAccess {
public $pidfile = '/var/run/phpd.pid';
public $defaultpidfile = '/var/run/phpd.pid';
public $configfile = '/etc/phpd/phpd.conf;./conf/phpd.conf';
public $path = './conf/appResolver.php';
public $path = './conf/AppResolver.php';
public $appfilepath = '{app-*,applications}/%s.php';
public $autoload = NULL;

Expand Down
26 changes: 11 additions & 15 deletions lib/HTTPRequest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function parseParams() {
}

if (isset($this->attrs->server['QUERY_STRING'])) {
$this->parse_str($this->attrs->server['QUERY_STRING'], $this->attrs->get);
HTTPRequest::parse_str($this->attrs->server['QUERY_STRING'], $this->attrs->get);
}

if (
Expand All @@ -153,7 +153,7 @@ public function parseParams() {
}

if (isset($this->attrs->server['HTTP_COOKIE'])) {
$this->parse_str(strtr($this->attrs->server['HTTP_COOKIE'], HTTPRequest::$hvaltr), $this->attrs->cookie);
HTTPRequest::parse_str(strtr($this->attrs->server['HTTP_COOKIE'], HTTPRequest::$hvaltr), $this->attrs->cookie);
}

if (isset($this->attrs->server['HTTP_AUTHORIZATION'])) {
Expand Down Expand Up @@ -185,7 +185,7 @@ public function postPrepare() {
&& ($this->attrs->server['REQUEST_METHOD'] == 'POST')
) {
if ($this->boundary === false) {
$this->parse_str($this->attrs->stdinbuf, $this->attrs->post);
HTTPRequest::parse_str($this->attrs->stdinbuf, $this->attrs->post);
}

if (
Expand Down Expand Up @@ -738,27 +738,23 @@ public function readBodyFile() {
* @param array Reference to the resulting array.
* @return void
*/
public function parse_str($s, &$array) {
public static function parse_str($s, &$array) {
static $cb;
if ($cb === NULL) {
$cb = function ($m) {
return urlencode(html_entity_decode('&#' . hexdec($m[1]) . ';', ENT_NOQUOTES, 'utf-8'));
};
}
if (
(stripos($s,'%u') !== false)
&& preg_match('~(%u[a-f\d]{4}|%[c-f][a-f\d](?!%[89a-f][a-f\d]))~is', $s, $m)
) {
$s = preg_replace_callback('~%(u[a-f\d]{4}|[a-f\d]{2})~i', array($this, 'parse_str_callback'), $s);
$s = preg_replace_callback('~%(u[a-f\d]{4}|[a-f\d]{2})~i', $cb, $s);
}

parse_str($s, $array);
}

/**
* Called in preg_replace_callback in parse_str
* @todo private?
* @param array Match
* @return string Replacement.
*/
public function parse_str_callback($m) {
return urlencode(html_entity_decode('&#' . hexdec($m[1]) . ';', ENT_NOQUOTES, 'utf-8'));
}

/**
* @todo description missing
* @todo protected?
Expand Down

0 comments on commit 1809a9c

Please sign in to comment.