| @@ 675-686 (lines=12) @@ | ||
| 672 | * |
|
| 673 | * @throws \InvalidArgumentException If the path is invalid. |
|
| 674 | */ |
|
| 675 | private function filterPath($path) |
|
| 676 | { |
|
| 677 | if (!is_string($path)) { |
|
| 678 | throw new \InvalidArgumentException('Path must be a string'); |
|
| 679 | } |
|
| 680 | ||
| 681 | return preg_replace_callback( |
|
| 682 | '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', |
|
| 683 | [$this, 'rawurlencodeMatchZero'], |
|
| 684 | $path |
|
| 685 | ); |
|
| 686 | } |
|
| 687 | ||
| 688 | /** |
|
| 689 | * Filters the query string or fragment of a URI. |
|
| @@ 697-708 (lines=12) @@ | ||
| 694 | * |
|
| 695 | * @throws \InvalidArgumentException If the query or fragment is invalid. |
|
| 696 | */ |
|
| 697 | private function filterQueryAndFragment($str) |
|
| 698 | { |
|
| 699 | if (!is_string($str)) { |
|
| 700 | throw new \InvalidArgumentException('Query and fragment must be a string'); |
|
| 701 | } |
|
| 702 | ||
| 703 | return preg_replace_callback( |
|
| 704 | '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', |
|
| 705 | [$this, 'rawurlencodeMatchZero'], |
|
| 706 | $str |
|
| 707 | ); |
|
| 708 | } |
|
| 709 | ||
| 710 | private function rawurlencodeMatchZero(array $match) |
|
| 711 | { |
|