This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,12 @@ public function setUri($uri)
76
76
$ e ->getCode (),
77
77
$ e
78
78
);
79
+ } catch (UriException \InvalidArgumentException $ e ) {
80
+ throw new Exception \InvalidArgumentException (
81
+ sprintf ('Invalid URI passed as string (%s) ' , (string ) $ uri ),
82
+ $ e ->getCode (),
83
+ $ e
84
+ );
79
85
}
80
86
} elseif (! ($ uri instanceof UriInterface)) {
81
87
throw new Exception \InvalidArgumentException ('URI must be an instance of Zend\Uri\Http or a string ' );
Original file line number Diff line number Diff line change @@ -77,4 +77,17 @@ public function testCRLFAttack()
77
77
$ this ->expectException (InvalidArgumentException::class);
78
78
Referer::fromString ("Referer: http://www.example.com/ \r\n\r\nevilContent " );
79
79
}
80
+
81
+ public function testInvalidUriShouldWrapException ()
82
+ {
83
+ $ headerString = "Referer: unknown-scheme://test " ;
84
+
85
+ $ headers = \Zend \Http \Headers::fromString ($ headerString );
86
+
87
+ $ result = $ headers ->get ('Referer ' );
88
+
89
+ $ this ->assertInstanceOf (\Zend \Http \Header \GenericHeader::class, $ result );
90
+ $ this ->assertNotInstanceOf (\Zend \Http \Header \Referer::class, $ result );
91
+ $ this ->assertEquals ('unknown-scheme://test ' , $ result ->getFieldValue ());
92
+ }
80
93
}
You can’t perform that action at this time.
0 commit comments