summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2015-08-12 15:27:39 +0200
committerChristian Schneider2015-08-12 15:27:39 +0200
commit1c0a580ec4de036530b08a83d5ddc2d915bdfd0b (patch)
treeda17deffd92927957246b5f3cb13393c853f0446
parent0bb7f6148acb2a4a4d2caaa83c9ffa5b27aa8e1c (diff)
parent79d5a50477ed74940484a5ca046dfa04adce1550 (diff)
downloaditools-1c0a580ec4de036530b08a83d5ddc2d915bdfd0b.tar.gz
itools-1c0a580ec4de036530b08a83d5ddc2d915bdfd0b.tar.bz2
itools-1c0a580ec4de036530b08a83d5ddc2d915bdfd0b.zip
Merge branch 'master' into cs/php7
-rw-r--r--it.class6
-rw-r--r--it_debug.class3
-rw-r--r--it_pipe.class3
-rw-r--r--it_url.class2
-rw-r--r--itjs.php1
-rwxr-xr-xtests/it.t27
-rwxr-xr-xtests/it_url.t42
-rwxr-xr-xtests/it_url_slow.t18
8 files changed, 51 insertions, 51 deletions
diff --git a/it.class b/it.class
index 494fb1b..c5c1179 100644
--- a/it.class
+++ b/it.class
@@ -266,7 +266,7 @@ static function fatal($p)
it::error($p);
if ($_SERVER['REMOTE_ADDR'])
header("HTTP/1.0 500 Internal Server Error");
- exit(1);
+ exit(99);
}
@@ -429,8 +429,8 @@ static function any2utf8($value, $errprefix = "")
if (is_array($value))
{
foreach ($value as $idx => $v)
- if (is_string($v) || is_array($v))
- $value[$idx] = self::any2utf8($v, $errprefix);
+ $newarr[self::any2utf8($idx)] = is_string($v) || is_array($v) ? self::any2utf8($v, $errprefix) : $v;
+ $value = (array)$newarr;
}
else if (is_string($value))
{
diff --git a/it_debug.class b/it_debug.class
index 6aab9eb..6a4c387 100644
--- a/it_debug.class
+++ b/it_debug.class
@@ -178,9 +178,6 @@ static function backtrace($p = array())
{
if (($fn = $call['file']) && !it::match($p['skipfiles'], $call['file']))
{
- if (!it::match('\.class|\.html', $call['file']) && @file_get_contents($call['file'], null, null, 0, 2) == "#!")
- $call['line']++; # fix bug in php error line reporting
-
$fn = (it::match('auto_prepend', $fn) ? basename(dirname(dirname($fn))) . "/" : "") . basename($fn);
$result[] = $fn . ":" . $call['line'];
diff --git a/it_pipe.class b/it_pipe.class
index 737908a..6b43466 100644
--- a/it_pipe.class
+++ b/it_pipe.class
@@ -168,7 +168,8 @@ function csv($forceschema = null)
foreach (preg_grep('/^$/', $cols) as $idx => $dummy)
$cols[$idx] = "field$idx"; # replace empty column names
- $oldlocale = setlocale(LC_CTYPE, 'de_CH.iso-8859-1'); # this works for utf-8 as well
+ $oldlocale = setlocale(LC_CTYPE, "0");
+ setlocale(LC_CTYPE, 'de_CH.iso-8859-1'); # this works for utf-8 as well
foreach ($this->lines as $line)
$records[] = (object)array_combine($cols, str_getcsv($line, $splitchar, '"')); # could do a function_exists('str_getcsv') here...
diff --git a/it_url.class b/it_url.class
index c465f13..984f621 100644
--- a/it_url.class
+++ b/it_url.class
@@ -385,7 +385,7 @@ function request($p=array())
if (time() >= $endtime) {
$result = $this->result = false;
- $errstr = $this->errstr = "totaltimeout reached";
+ $errstr = $this->errstr = "totaltimeout (" . $p['totaltimeout'] . ") reached";
}
if ($p['maxlength'] && (strlen($this->data) + $len > $p['maxlength'])) {
diff --git a/itjs.php b/itjs.php
index 88fe03f..332e0dc 100644
--- a/itjs.php
+++ b/itjs.php
@@ -60,6 +60,7 @@ else if (it::match('\.css', $file))
':valid:' => ":", # hack for iOS datetime
'([^/])\*(\w)' => '$1$2',
'svg\..*' => "", # ignore svg styles
+ '\battr\(.*?\)' => "'x'", # ignore content:attr(placeholder)
),
$data
);
diff --git a/tests/it.t b/tests/it.t
index a50b4dc..10c4d0e 100755
--- a/tests/it.t
+++ b/tests/it.t
@@ -58,25 +58,25 @@ match(
match(
'\bblah\b', 'ablahc',
- false,
+ null,
'don\'t match \b at word chars'
);
match(
'\bblah\b', 'Üblahä',
- false,
+ null,
'don\'t match \b at umlaute'
);
match(
'\Bblah\B', ' blah ',
- false,
+ null,
'don\'t match \B at spaces'
);
match(
'\Bblah\B', 'blah',
- false,
+ null,
'don\'t match \B at end of string'
);
@@ -112,7 +112,7 @@ match(
match(
'\ba', 'äa',
- '',
+ null,
'\b must know umlauts'
);
@@ -133,19 +133,19 @@ $escapedwordregex = preg_replace('|[\\\\/]|', '', $escapedwordregex);
match(
'\\\\w+', $escapedwordregex,
- false,
+ null,
'don\'t parse \w in \\\\w at beginning (no match)'
);
match(
'aaa\\\\w+', 'aaa' . $escapedwordregex,
- false,
+ null,
'don\'t parse \w in \\\\w after chars (no match)'
);
match(
'\\\\\\\\w+', '\\' . $escapedwordregex,
- false,
+ null,
'don\'t parse \w in \\\\\\\w (no match)'
);
@@ -157,7 +157,7 @@ match(
match(
'[\w]+', '[[[]]]---',
- false,
+ null,
'replace \w in [\w] correctly (no match)'
);
@@ -169,7 +169,7 @@ match(
match(
'[\\\\w]+', ' blabergna ',
- false,
+ null,
'don\'t parse \w in [\\\\w] (no match)'
);
@@ -239,9 +239,9 @@ match(
match(
'abc', "aBc",
- false,
+ null,
"set case sensitivity by parameter",
- array('casesensitive' => 1),
+ array('casesensitive' => 1)
);
match(
@@ -309,7 +309,7 @@ is(it::replace(array('a' => "b", 'b' => "c"), "a"), "c");
is(it::grep('ismatch', array('ismatch', 'isnomatch')), array('ismatch'), 'grep with simple regex');
is(it::grep('!', array('ismatch!', 'isnomatch')), array('ismatch!'), '! in regex');
-is(it::grep('lower|UPPER', array('lower', 'LOWER', 'upper', 'UPPER'), 'casesensitive' => 1), array(0 => 'lower', 3 => 'UPPER'), 'set casesensitive');
+is(it::grep('lower|UPPER', array('lower', 'LOWER', 'upper', 'UPPER'), array('casesensitive' => 1)), array(0 => 'lower', 3 => 'UPPER'), 'set casesensitive');
is(it::grep('match', array('foo' => 'match', 'bar' => 'gna')), array('foo' => 'match'), 'with keys');
setlocale(LC_CTYPE, $oldlocale);
@@ -389,6 +389,7 @@ is(it::any2utf8("a💚b"), "a💚b", "it::any2utf8 correctly handles 4-byte utf-
is(it::any2utf8(array("foo", utf8_decode("bär"))), array("foo", "bär"), "any2utf8 on arrays");
is(it::any2utf8(array("foo", array(utf8_decode("bär")))), array("foo", array("bär")), "any2utf8 on recursive arrays");
is(it::any2utf8(array(1, true, false, null)), array(1, true, false, null), "any2utf8 should leave types alone");
+is(it::any2utf8(array(utf8_decode('Müller') => utf8_decode('Müller'))), array('Müller' => 'Müller'), "it::any2utf8 latin1 keys");
foreach (array($dummy, false, true, null, 1, "a", "Ä", "/", array()) as $var)
is(it::json_decode(it::json_encode($var)), $var);
diff --git a/tests/it_url.t b/tests/it_url.t
index 711b5f1..5cb2b29 100755
--- a/tests/it_url.t
+++ b/tests/it_url.t
@@ -109,7 +109,7 @@ ok(
);
is(
$url->result,
- 200,
+ '200',
'$url->result = 200'
);
is(
@@ -131,7 +131,7 @@ handle_server(
is(
it_url::get('http://localhost:8000/'),
"Testserver root output",
- 'it_url::get() static call with port',
+ 'it_url::get() static call with port'
)
);
@@ -139,7 +139,7 @@ handle_server(
is(
it_url::get(array('url' => 'http://localhost:8000/', 'maxlength' => 100)),
"Testserver root output",
- 'it_url::get() static call with port and maxlength',
+ 'it_url::get() static call with port and maxlength'
)
);
@@ -147,7 +147,7 @@ handle_server(
is(
it_url::get(array('url' => 'http://localhost:8000/', 'maxlength' => 5)),
false,
- 'it_url::get() static call with port and too small maxlength',
+ 'it_url::get() static call with port and too small maxlength'
)
);
@@ -155,7 +155,7 @@ handle_server(
is(
it_url::get('http://localhost:8000/temp_redirect'),
"Testserver output after temporary redirect",
- 'it_url::get() follows temproary redirect',
+ 'it_url::get() follows temproary redirect'
)
);
@@ -163,7 +163,7 @@ handle_server(
is(
it_url::get('http://localhost:8000/perm_redirect'),
"Testserver output after permanent redirect",
- 'it_url::get() follows permanent redirect',
+ 'it_url::get() follows permanent redirect'
)
);
@@ -171,7 +171,7 @@ handle_server(
is(
it_url::get('http://localhost:8000/relative_redirect'),
"Testserver output after relative redirect",
- 'TODO: it_url::get() follows relative redirect correctly',
+ 'TODO: it_url::get() follows relative redirect correctly'
)
);
@@ -179,59 +179,59 @@ handle_server(
is(
it_url::get('http://localhost:8000/nohost_redirect'),
"Testserver output after nohost redirect",
- 'TODO: it_url::get() follows redirect without host correctly',
+ 'TODO: it_url::get() follows redirect without host correctly'
)
);
$output = handle_server(
ok(
- !it_url::get(U('http://localhost:8000/redirect_loop', 'num' => 10)),
- 'it_url::get() handles redirect loop',
+ !it_url::get(U('http://localhost:8000/redirect_loop', array('num' => 10))),
+ 'it_url::get() handles redirect loop'
)
);
$last_num = it::match('num=(\d+)', end($output));
if (!ok(
$last_num == 5,
- 'it_url::get() aborts redirect loop after 5 redirects',
+ 'it_url::get() aborts redirect loop after 5 redirects'
))
diag($output);
$output = handle_server(
ok(
- !it_url::get('url' => 'http://localhost:8000/does_not_exist', 'retries' => 4),
- 'it_url::get() retries on empty response',
+ !it_url::get(array('url' => 'http://localhost:8000/does_not_exist', 'retries' => 4)),
+ 'it_url::get() retries on empty response'
)
);
if (!ok(
count(preg_grep('/^Got Request:/', $output)) == 5,
- 'it_url::get() respects set retry count',
+ 'it_url::get() respects set retry count'
))
diag($output);
handle_server(
is(
- it_url::get(U('http://localhost:8000/get_server_value', 'key' => 'HTTP_HOST')),
+ it_url::get(U('http://localhost:8000/get_server_value', array('key' => 'HTTP_HOST'))),
'localhost:8000',
- 'it_url::get() sets correct Host header',
+ 'it_url::get() sets correct Host header'
)
);
handle_server(
is(
- it_url::get(U('http://localhost:8000/get_server_value', 'key' => 'HTTP_ACCEPT_LANGUAGE')),
+ it_url::get(U('http://localhost:8000/get_server_value', array('key' => 'HTTP_ACCEPT_LANGUAGE'))),
T_lang(),
- 'it_url::get() sets correct Accept-Language header',
+ 'it_url::get() sets correct Accept-Language header'
)
);
handle_server(
ok(
- it::match('Mozilla', it_url::get(U('http://localhost:8000/get_server_value', 'key' => 'HTTP_USER_AGENT'))),
- 'it_url::get() sets User-Agent containing Mozilla',
+ it::match('Mozilla', it_url::get(U('http://localhost:8000/get_server_value', array('key' => 'HTTP_USER_AGENT')))),
+ 'it_url::get() sets User-Agent containing Mozilla'
)
);
-$pages = it_url::get_multi('urls' => array('a' => 'http://www.gna.ch/', 'b' => 'http://search.ch/'));
+$pages = it_url::get_multi(array('urls' => array('a' => 'http://www.gna.ch/', 'b' => 'http://search.ch/')));
ok(strpos($pages['a'], '</html>'), 'it_url::get_multi got first url'); # UTF8SAFE
ok(strpos($pages['b'], '</html>'), 'it_url::get_multi got second url'); # UTF8SAFE
is(count($pages), 2, 'it_url::get_multi no additional array elements');
diff --git a/tests/it_url_slow.t b/tests/it_url_slow.t
index 74440ce..68d68c1 100755
--- a/tests/it_url_slow.t
+++ b/tests/it_url_slow.t
@@ -11,18 +11,18 @@ handle_server(
is(
it_url::get('http://localhost:8000/short_sleep'),
"Testserver output after short sleep",
- 'it_url::get() waits for 4 seconds',
+ 'it_url::get() waits for 4 seconds'
)
);
$start = microtime(true);
$res = ok(
!it_url::get(array('url' => 'http://localhost:8000/long_sleep', 'timeout' => 5, 'retries' => 0)),
- 'it_url::get() fails after timeout seconds with no output',
+ 'it_url::get() fails after timeout seconds with no output'
);
$res2 = is(
- floor(microtime(true) - $start), 5,
- '... and fails as soon as timeout is surpassed',
+ intval(microtime(true) - $start), 5,
+ '... and fails as soon as timeout is surpassed'
);
sleep(1); # wait for testserver
$output = server_output();
@@ -33,17 +33,17 @@ handle_server(
is(
it_url::get('http://localhost:8000/slow_response'),
join('', it::map('"Testserver slow output $v\n"', range(0, 5))),
- 'it_url::get() waits for slow response with continuous output',
+ 'it_url::get() waits for slow response with continuous output'
)
);
$start = microtime(true);
$res = ok(
!it_url::get(array('url' => 'http://localhost:8000/slow_response', 'totaltimeout' => 5, 'retries' => 0)),
- 'it_url::get() fails for response slower than totaltimeout',
+ 'it_url::get() fails for response slower than totaltimeout'
);
$res2 = is(
- floor(microtime(true) - $start), 5,
+ intval(microtime(true) - $start), 5,
'... and fails as soon as totaltimeout is surpassed'
);
sleep(1); # wait for testserver
@@ -53,8 +53,8 @@ if (!$res || !$res2)
handle_server(
ok(
- it_url::get(U('http://localhost:8000/repeat', 'string' => "abc", 'num' => 1024 * 1024)) == str_repeat("abc", 1024 * 1024),
- 'it_url::get() handles large response',
+ it_url::get(U('http://localhost:8000/repeat', array('string' => "abc", 'num' => 1024 * 1024))) == str_repeat("abc", 1024 * 1024),
+ 'it_url::get() handles large response'
)
);