diff options
-rw-r--r-- | it_url.class | 6 | ||||
-rw-r--r-- | it_xml.class | 3 | ||||
-rwxr-xr-x | test/it.t | 82 | ||||
-rwxr-xr-x | test/it_text.t | 2 | ||||
-rwxr-xr-x | test/it_xml.t | 24 |
5 files changed, 61 insertions, 56 deletions
diff --git a/it_url.class b/it_url.class index 6b1f81c..c1d7ec5 100644 --- a/it_url.class +++ b/it_url.class @@ -361,13 +361,13 @@ static function get_multi($p=null) curl_setopt($handle, CURLOPT_URL, it::replace([ '^//' => "http://" ], is_array($url) ? $url['url'] : $url)); curl_setopt_array($handle, $opts); curl_multi_add_handle($mh, $handle); - $keys[$handle] = $key; + $keys[(int)$handle] = $key; $handles[$key] = $handle; }; $closehandle = function ($key) use (&$keys, &$handles, $mh) { curl_multi_remove_handle($mh, $handles[$key]); curl_close($handles[$key]); - unset($keys[$handles[$key]]); + unset($keys[(int)$handles[$key]]); unset($handles[$key]); }; @@ -406,7 +406,7 @@ static function get_multi($p=null) { if ($info['msg'] == CURLMSG_DONE) { - $key = $keys[$info['handle']]; + $key = $keys[(int)$info['handle']]; $content = curl_multi_getcontent($info['handle']); if (isset($p['postprocess'])) $content = $p['postprocess']($content, ['it_error' => $retries[$key] < $p['retries'] ? false : (array)$p['it_error'] + ['title' => "invalid content from " . $urls[$key]]]); diff --git a/it_xml.class b/it_xml.class index 2e687e1..93f8b4d 100644 --- a/it_xml.class +++ b/it_xml.class @@ -209,6 +209,9 @@ function end_element($dummy_parser, $name) if (!$this->_stack[0]->consume($this->_p)) { + if (!isset($this->_stack[1])) + $this->_stack[1] = (object)[]; + if (is_array($this->_stack[1]->$name)) array_push($this->_stack[1]->$name, $this->_stack[0]); else if (isset($this->_stack[1]->$name)) @@ -12,7 +12,7 @@ $oldlocale = setlocale(LC_CTYPE, 0); ini_set('default_charset', 'utf-8'); setlocale(LC_CTYPE, 'de_CH'); # required becuase we're checking German umlauts in latin1 mode -function match($regex, $string, $expect, $name, $p = []) +function _match($regex, $string, $expect, $name, $p = []) { $GLOBALS['TEST_MORE_LEVEL'] = 1; $pass = is (it::match($regex, $string, $p), $expect, $name); @@ -24,103 +24,103 @@ function match($regex, $string, $expect, $name, $p = []) } -match( +_match( 'b', 'aaaabaaaa', 'b', 'simple regex' ); -match( +_match( 'a/b', ' a/b ', 'a/b', 'regex with /' ); -match( +_match( 'aa(bb)aa(cc)aa(dd)qq', 'aabbaaccaaddqq', ['bb', 'cc', 'dd'], 'return array of captures' ); -match( +_match( '\bblah\b', ' blah ', 'blah', 'match \b at spaces' ); -match( +_match( '\bblah\b', 'blah', 'blah', 'match \b at end of string' ); -match( +_match( '\bblah\b', 'ablahc', null, 'don\'t match \b at word chars' ); -match( +_match( '\bblah\b', 'Üblahä', null, 'don\'t match \b at umlaute' ); -match( +_match( '\Bblah\B', ' blah ', null, 'don\'t match \B at spaces' ); -match( +_match( '\Bblah\B', 'blah', null, 'don\'t match \B at end of string' ); -match( +_match( '\Bblah\B', 'ablahc', 'blah', 'match \B at word chars' ); -match( +_match( '\Bblah\B', 'Üblahä', 'blah', 'match \B at umlaute' ); -match( +_match( '\w+', ' |#Üblahä ', 'Üblahä', 'include umlaute in \w' ); -match( +_match( '[[:alpha:]]+', ' |#blahä ', 'blahä', 'include umlaute in [[:alpha:]]' ); -match( +_match( '\W+', ' |#Üblahä ', ' |#', 'don\'t include umlaute in \W' ); -match( +_match( '\ba', 'äa', null, '\b must know umlauts' ); -match( +_match( 'aaa\\\\w+', ' aaa\www ', 'aaa\www', 'don\'t parse \w in \\\\w at beginning (match)' ); -match( +_match( 'aaa\\\\w+', ' aaa\www ', 'aaa\www', 'don\'t parse \w in \\\\w after chars (match)' @@ -129,105 +129,105 @@ match( eval('$escapedwordregex = "' . it::convertregex('\w') . '";'); $escapedwordregex = preg_replace('|[\\\\/]|', '', $escapedwordregex); -match( +_match( '\\\\w+', $escapedwordregex, null, 'don\'t parse \w in \\\\w at beginning (no match)' ); -match( +_match( 'aaa\\\\w+', 'aaa' . $escapedwordregex, null, 'don\'t parse \w in \\\\w after chars (no match)' ); -match( +_match( '\\\\\\\\w+', '\\' . $escapedwordregex, null, 'don\'t parse \w in \\\\\\\w (no match)' ); -match( +_match( '\\\\\\\\w+', ' \\\\www ', '\\\\www', 'don\'t parse \\\\\\\\w as \w (match)' ); -match( +_match( '[\w]+', '[[[]]]---', null, 'replace \w in [\w] correctly (no match)' ); -match( +_match( '[\w]+', ' \\\\aword[[[]]] ', 'aword', 'replace \w in [\w] correctly (match)' ); -match( +_match( '[\\\\w]+', ' blabergna ', null, 'don\'t parse \w in [\\\\w] (no match)' ); -match( +_match( '[\\\\w]+', ' \\\\worda[[[]', '\\\\w', 'don\'t parse \w in [\\\\w] (match)' ); -match( +_match( '[a\W]+', 'bbbbbbb a a%$+ accccc', ' a a%$+ a', '\W in []' ); -match( +_match( '\\\\\\w+', ' \Üblahä ', '\Üblahä', 'parse \w in \\\\\\w at beginning' ); -match( +_match( 'aaa\\\\\\w+', ' aaa\Üblahä ', 'aaa\Üblahä', 'parse \w in \\\\\\w after chars' ); -match( +_match( '\w+', 'word1 wörd2 word_3', ['word1', 'wörd2', 'word_3'], "test match_all function", ['all' => true] ); -match( +_match( 'aBcD', ' aBcD ', 'aBcD', "caseinsensitive is default" ); -match( +_match( '\w+', 'Müller', 'Müller', '\w matches umlaut in utf-8 mode' ); -match( +_match( 'M.ller', 'Müller', 'Müller', '. matches umlaut in utf-8 mode' ); -match( +_match( utf8_decode('ö'), utf8_decode('Ö'), utf8_decode('Ö'), 'match umlaute in de_CH.latin1 case insensitive', ['utf8' => false] ); -match( +_match( utf8_decode('aöBÜ'), utf8_decode('AÖbü'), utf8_decode('AÖbü'), "match umlaute with non-utf-8 override in p", @@ -235,35 +235,35 @@ match( ); -match( +_match( 'abc', "aBc", null, "set case sensitivity by parameter", ['casesensitive' => 1] ); -match( +_match( '\w+', 'word1 wörd2 word_3', ['word1', 'wörd2', 'word_3'], "test all => 1 without captures", ['all' => 1] ); -match( +_match( '\w+\s+(\d+)', 'word1 12 wörd2 3 word_3 4', ['12', '3', '4'], "test all => 1 with one capture", ['all' => 1] ); -match( +_match( '(\w+)\s+(\d+)', 'word1 12 wörd2 3 word_3 4', [['word1', '12'], ['wörd2', '3'], ['word_3', '4']], "test all => 1 with captures", ['all' => 1] ); -match( +_match( '(\w+)\s+(\d+)', 'word1 12 wörd2 3 word_3 4', [['word1', 'wörd2', 'word_3'], ['12', '3', '4']], "test all => 1,pattern_order => 1", @@ -271,7 +271,7 @@ match( ); ini_set('default_charset', 'iso-8859-1'); -match( +_match( 'aöBÜ', "AÖbü", 'AÖbü', "match utf-8 umlaute in case insensitive mode with utf8 override", diff --git a/test/it_text.t b/test/it_text.t index 5629d51..6726996 100755 --- a/test/it_text.t +++ b/test/it_text.t @@ -1,7 +1,9 @@ #!/www/server/bin/php <?php +$obj = (object)[]; $obj->x = "attr"; +$obj->y = (object)[]; $obj->y->z = "attr"; is(it_text::transmogrify(""), ""); diff --git a/test/it_xml.t b/test/it_xml.t index 27f910f..e21f052 100755 --- a/test/it_xml.t +++ b/test/it_xml.t @@ -3,7 +3,7 @@ # Tests for xml.class -function match($xmldata, $expected, $name, $prefix = "", $p = []) +function _match($xmldata, $expected, $name, $prefix = "", $p = []) { $classname = ($prefix ?: "it") . "_xml"; $varname = $prefix . "foo"; @@ -31,37 +31,37 @@ function match($xmldata, $expected, $name, $prefix = "", $p = []) ); } -match( +_match( '<foo />', 'foo Object ( ) ', 'empty tag' ); -match( +_match( '<foo /><foo />', 'Array ( [0] => foo Object ( ) [1] => foo Object ( ) ) ', 'multiple empty tags converted to array' ); -match( +_match( '<foo title="Zürich">Stüssihofstadt</foo>', 'foo Object ( [attr] => Array ( [title] => Zürich ) [val] => Stüssihofstadt ) ', 'simple tag with latin1 content and attribute' ); -match( +_match( '<foo><ns:a.b.-c ns2:d.e-f="value" /></foo>', 'foo Object ( [a_b__c] => a_b__c Object ( [attr] => Array ( [d_e_f] => value ) ) ) ', 'Tags and attributes with name space and special characters' ); -match( +_match( '<foo>x & y</foo>', 'foo Object ( [val] => x & y ) ', 'Character data with entities' ); -match( +_match( '<foo>x ü y</foo>', utf8_decode('foo Object ( [val] => x ü y ) '), 'Manual encoding override', @@ -69,13 +69,13 @@ match( ['encoding' => "iso-8859-1"] ); -match( +_match( '<foo>&amp; <a> &amp; <b> &amp; <c> ü</foo>', 'foo Object ( [val] => & <a> & <b> & <c> ü ) ', 'Predecode illegal entities while keeping properly encoded ones' ); -match( +_match( '<foo>&amp; <a> &amp; <b> &amp; <c> ü</foo>', utf8_decode('foo Object ( [val] => & <a> & <b> & <c> ü ) '), 'Predecode illegal entities while keeping properly encoded ones (iso-8859-1)', @@ -83,7 +83,7 @@ match( ['encoding' => "iso-8859-1"] ); -match( +_match( "<foo>a\x05b</foo>", 'foo Object ( [val] => a b ) ', 'Illegal latin 1 character', @@ -109,7 +109,7 @@ function __construct($xmldata) } -match( +_match( '<myfoo />', 'myfoo Object ( [inheritbaseclass] => ) ', 'Inheritance and constructor (critical for e.g. tel_xmlentry)', @@ -118,7 +118,7 @@ match( $x = new foo("<foo></foo>", ['prefix' => "test"]); $x->set(['gna' => 42, 'bar' => ['baz' => ["qux", "quux"]]]); -match( +_match( $x->to_xml(), 'foo Object ( [gna] => gna Object ( [val] => 42 ) [bar] => bar Object ( [baz] => Array ( [0] => baz Object ( [val] => qux ) [1] => baz Object ( [val] => quux ) ) ) ) ', "Method set()" |