File tree Expand file tree Collapse file tree 4 files changed +6
-4
lines changed Expand file tree Collapse file tree 4 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ All Notable changes to `League\Uri` will be documented in this file
2323- ` Uri ` and ` Http ` normalization normalized IP against RFC3986 rules and not WHATWG rules.
2424- ` Uri::getOrigin ` now follows WHATWG cross-origin definition
2525- ` Uri ` host encoding compliance to RFC3986 is improved by supporting RFC3986 encoded URI properly
26+ - ` Uri ` parsing with strings started or ended with empty string are no longer allowed
27+ - ` Uri ` space are rawurlencoded.
2628
2729### Deprecated
2830
Original file line number Diff line number Diff line change @@ -566,8 +566,6 @@ public static function invalidUriWithWhitespaceProvider(): iterable
566566 yield 'uri containing only whitespaces ' => ['uri ' => ' ' ];
567567 yield 'uri starting with whitespaces ' => ['uri ' => ' https://a/b?c ' ];
568568 yield 'uri ending with whitespaces ' => ['uri ' => 'https://a/b?c ' ];
569- yield 'uri surrounded by whitespaces ' => ['uri ' => ' https://a/b?c ' ];
570- yield 'uri containing whitespaces ' => ['uri ' => 'https://a/b ?c ' ];
571569 }
572570
573571 #[Test]
Original file line number Diff line number Diff line change @@ -49,6 +49,5 @@ public static function invalidUriWithWhitespaceProvider(): iterable
4949 yield 'uri starting with whitespaces ' => ['uri ' => ' https://a/b?c ' ];
5050 yield 'uri ending with whitespaces ' => ['uri ' => 'https://a/b?c ' ];
5151 yield 'uri surrounded with whitespaces ' => ['uri ' => ' https://a/b?c ' ];
52- yield 'uri containing whitespaces ' => ['uri ' => 'https://a/b ?c ' ];
5352 }
5453}
Original file line number Diff line number Diff line change @@ -478,7 +478,10 @@ public static function tryNew(Stringable|string|null $uri = ''): ?self
478478 */
479479 public static function new (Stringable |string $ uri = '' ): self
480480 {
481- return new self (...UriString::parse ($ uri ));
481+ $ uri = (string ) $ uri ;
482+ trim ($ uri ) === $ uri || throw new SyntaxError (sprintf ('The uri `%s` contains invalid characters ' , $ uri ));
483+
484+ return new self (...UriString::parse (str_replace (' ' , '%20 ' , $ uri )));
482485 }
483486
484487 /**
You can’t perform that action at this time.
0 commit comments