summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2022-10-25 15:51:10 +0200
committerUrban Müller2022-10-25 15:51:10 +0200
commitcb55bfaf566ef14c41024c5441b8c2425a212578 (patch)
tree0a2373519ad0e1cded726486bff83e7a2c723be7
parent53e71626424285dbed893ee615c98fa378c30b19 (diff)
downloaditools-cb55bfaf566ef14c41024c5441b8c2425a212578.tar.gz
itools-cb55bfaf566ef14c41024c5441b8c2425a212578.tar.bz2
itools-cb55bfaf566ef14c41024c5441b8c2425a212578.zip
be utf8 safe
-rw-r--r--it_url.class11
-rwxr-xr-xtest/it_url.t1
2 files changed, 6 insertions, 6 deletions
diff --git a/it_url.class b/it_url.class
index 6058346..cc5f816 100644
--- a/it_url.class
+++ b/it_url.class
@@ -613,7 +613,7 @@ static function get_cache($p = array())
if ($data = $url->_get($p + ['checkonly' => true, 'filemtime' => EDC('nocache') ? null : $filemtime])) # => true means not modified (no new data fetched)
{
$success = true;
- $newfile = it_url::_atomicwrite($path, $p['assoc'] ? serialize($data) : $data);
+ $isnewfile = it_url::_atomicwrite($path, $p['assoc'] ? serialize($data) : $data);
if ($p['returnheaders'])
it::file_put_contents("$path.headers", '<?php return ' . var_export($url->headers, true) . ";\n");
}
@@ -652,7 +652,7 @@ static function get_cache($p = array())
$srcpath = $path;
$path .= substr(md5(serialize($p['preprocess'])), 0, 2);
- if ($filemtime = $newfile ? true : it_url::_expired($path, $p['maxage'])) # Outdated(non-zero int) or non-existant(true)?
+ if ($filemtime = $isnewfile ? true : it_url::_expired($path, $p['maxage'])) # Outdated(non-zero int) or non-existant(true)?
{
if ($lock = !$p['lock'] ?: it_url::_lock($path))
{
@@ -696,7 +696,7 @@ static function get_cache($p = array())
}
if (EDC('getcachelog'))
- it::log('debug', 'getcachelog', $p['id'], $p['url'], $newfile && is_string($data) ? "fetched=" . mb_substr($data, 0, 500) : "");
+ it::log('debug', 'getcachelog', $p['id'], $p['url'], !$isnewfile ? "" : "fetched=" . mb_substr(is_string($data) ? $data : "(assoc)", 0, 400));
### EDC('getcache', $success, $path); # too verbose
return $success ? ($p['returnheaders'] ? array($path, $headers) : $path) : false;
@@ -934,7 +934,7 @@ static function parse_str($query)
foreach (explode('&', $query) as $arg)
{
list($key, $value) = explode('=', $arg, 2);
- $result[urldecode($key)] = urldecode($value);
+ $result[it::urldecode($key)] = it::urldecode($value);
}
return (array)$result;
@@ -947,8 +947,7 @@ static function parse_str($query)
static function parse($url)
{
list($path, $query) = explode("?", $url, 2);
- parse_str((string)$query, $params);
- return (array)$path + (array)$params;
+ return (array)$path + (array)it::parse_str((string)$query);
}
}
diff --git a/test/it_url.t b/test/it_url.t
index 360b971..d2bb653 100755
--- a/test/it_url.t
+++ b/test/it_url.t
@@ -340,3 +340,4 @@ handle_server(
is(it_url::parse("/foo"), ["/foo"], "it_url::parse path only");
is(it_url::parse("/foo?"), ["/foo"], "it_url::parse empty parameter");
is(it_url::parse("/foo?bar=baz&qux=quux"), ["/foo", 'bar' => "baz", 'qux' => "quux"], "it_url::parse parameters");
+is(it_url::parse("/foo?b%E4r=b%E4z"), ["/foo", 'bär' => "bäz"]);