add missing test
authorMichael Wallner <mike@php.net>
Fri, 25 Sep 2015 11:27:50 +0000 (13:27 +0200)
committerMichael Wallner <mike@php.net>
Fri, 25 Sep 2015 11:27:50 +0000 (13:27 +0200)
tests/gh-issue12.phpt [new file with mode: 0644]

diff --git a/tests/gh-issue12.phpt b/tests/gh-issue12.phpt
new file mode 100644 (file)
index 0000000..0721586
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+crash with bad url passed to http\Message::setRequestUrl()
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php 
+echo "Test\n";
+
+$urls = array(
+               "http://.foo.bar",
+               "http://foo..bar",
+               "http://foo.bar.",
+);
+
+foreach ($urls as $url) {
+       try {
+               (new http\Client\Request)->setRequestUrl($url);
+               printf("OK: %s\n", $url);
+       } catch (Exception $e) {
+               printf("%s\n", $e->getMessage());
+       }
+}
+
+?>
+===DONE===
+--EXPECT--
+Test
+http\Message::setRequestUrl(): Failed to parse host; unexpected '.' at pos 0 in '.foo.bar'
+http\Message::setRequestUrl(): Failed to parse host; unexpected '.' at pos 4 in 'foo..bar'
+OK: http://foo.bar.
+===DONE===