Changeset 47733 for trunk/src/wp-includes/SimplePie/IRI.php
- Timestamp:
- 05/01/2020 02:24:42 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/IRI.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 48 47 * @package SimplePie 49 48 * @subpackage HTTP 50 * @author GeoffreySneddon49 * @author Sam Sneddon 51 50 * @author Steve Minutillo 52 51 * @author Ryan McCue 53 * @copyright 2007-2012 GeoffreySneddon, Steve Minutillo, Ryan McCue52 * @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue 54 53 * @license http://www.opensource.org/licenses/bsd-license.php 55 54 */ … … 213 212 return $this->normalization[$this->scheme][$name]; 214 213 } 215 else 216 { 217 return $return; 218 } 214 215 return $return; 219 216 } 220 217 … … 227 224 public function __isset($name) 228 225 { 229 if (method_exists($this, 'get_' . $name) || isset($this->$name)) 230 { 231 return true; 232 } 233 else 234 { 235 return false; 236 } 226 return method_exists($this, 'get_' . $name) || isset($this->$name); 237 227 } 238 228 … … 258 248 { 259 249 $this->set_iri($iri); 250 } 251 252 /** 253 * Clean up 254 */ 255 public function __destruct() { 256 $this->set_iri(null, true); 257 $this->set_path(null, true); 258 $this->set_authority(null, true); 260 259 } 261 260 … … 349 348 return $target; 350 349 } 351 else 352 { 353 return false; 354 } 350 351 return false; 355 352 } 356 353 } … … 389 386 return $match; 390 387 } 391 else 392 { 393 // This can occur when a paragraph is accidentally parsed as a URI 394 return false; 395 } 388 389 // This can occur when a paragraph is accidentally parsed as a URI 390 return false; 396 391 } 397 392 … … 769 764 public function is_valid() 770 765 { 771 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; 772 if ($this->ipath !== '' && 773 ( 774 $isauthority && ( 775 $this->ipath[0] !== '/' || 776 substr($this->ipath, 0, 2) === '//' 777 ) || 778 ( 779 $this->scheme === null && 780 !$isauthority && 781 strpos($this->ipath, ':') !== false && 782 (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) 783 ) 784 ) 785 ) 786 { 787 return false; 788 } 766 if ($this->ipath === '') return true; 767 768 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || 769 $this->port !== null; 770 if ($isauthority && $this->ipath[0] === '/') return true; 771 772 if (!$isauthority && (substr($this->ipath, 0, 2) === '//')) return false; 773 774 // Relative urls cannot have a colon in the first path segment (and the 775 // slashes themselves are not included so skip the first character). 776 if (!$this->scheme && !$isauthority && 777 strpos($this->ipath, ':') !== false && 778 strpos($this->ipath, '/', 1) !== false && 779 strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false; 789 780 790 781 return true; … … 798 789 * @return bool 799 790 */ 800 public function set_iri($iri )791 public function set_iri($iri, $clear_cache = false) 801 792 { 802 793 static $cache; 794 if ($clear_cache) 795 { 796 $cache = null; 797 return; 798 } 803 799 if (!$cache) 804 800 { … … 822 818 return $return; 823 819 } 824 else 825 { 826 $parsed = $this->parse_iri((string) $iri); 827 if (!$parsed) 828 { 829 return false; 830 } 831 832 $return = $this->set_scheme($parsed['scheme']) 833 && $this->set_authority($parsed['authority']) 834 && $this->set_path($parsed['path']) 835 && $this->set_query($parsed['query']) 836 && $this->set_fragment($parsed['fragment']); 837 838 $cache[$iri] = array($this->scheme, 839 $this->iuserinfo, 840 $this->ihost, 841 $this->port, 842 $this->ipath, 843 $this->iquery, 844 $this->ifragment, 845 $return); 846 return $return; 847 } 820 821 $parsed = $this->parse_iri((string) $iri); 822 if (!$parsed) 823 { 824 return false; 825 } 826 827 $return = $this->set_scheme($parsed['scheme']) 828 && $this->set_authority($parsed['authority']) 829 && $this->set_path($parsed['path']) 830 && $this->set_query($parsed['query']) 831 && $this->set_fragment($parsed['fragment']); 832 833 $cache[$iri] = array($this->scheme, 834 $this->iuserinfo, 835 $this->ihost, 836 $this->port, 837 $this->ipath, 838 $this->iquery, 839 $this->ifragment, 840 $return); 841 return $return; 848 842 } 849 843 … … 880 874 * @return bool 881 875 */ 882 public function set_authority($authority )876 public function set_authority($authority, $clear_cache = false) 883 877 { 884 878 static $cache; 879 if ($clear_cache) 880 { 881 $cache = null; 882 return; 883 } 885 884 if (!$cache) 886 885 $cache = array(); … … 902 901 return $return; 903 902 } 903 904 $remaining = $authority; 905 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) 906 { 907 $iuserinfo = substr($remaining, 0, $iuserinfo_end); 908 $remaining = substr($remaining, $iuserinfo_end + 1); 909 } 904 910 else 905 911 { 906 $remaining = $authority; 907 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) 908 { 909 $iuserinfo = substr($remaining, 0, $iuserinfo_end); 910 $remaining = substr($remaining, $iuserinfo_end + 1); 911 } 912 else 913 { 914 $iuserinfo = null; 915 } 916 if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) 917 { 918 if (($port = substr($remaining, $port_start + 1)) === false) 919 { 920 $port = null; 921 } 922 $remaining = substr($remaining, 0, $port_start); 923 } 924 else 912 $iuserinfo = null; 913 } 914 if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) 915 { 916 if (($port = substr($remaining, $port_start + 1)) === false) 925 917 { 926 918 $port = null; 927 919 } 928 929 $return = $this->set_userinfo($iuserinfo) && 930 $this->set_host($remaining) && 931 $this->set_port($port); 932 933 $cache[$authority] = array($this->iuserinfo, 934 $this->ihost, 935 $this->port, 936 $return); 937 938 return $return; 939 } 920 $remaining = substr($remaining, 0, $port_start); 921 } 922 else 923 { 924 $port = null; 925 } 926 927 $return = $this->set_userinfo($iuserinfo) && 928 $this->set_host($remaining) && 929 $this->set_port($port); 930 931 $cache[$authority] = array($this->iuserinfo, 932 $this->ihost, 933 $this->port, 934 $return); 935 936 return $return; 940 937 } 941 938 … … 1037 1034 return true; 1038 1035 } 1039 else 1040 { 1041 $this->port = null; 1042 return false; 1043 } 1036 1037 $this->port = null; 1038 return false; 1044 1039 } 1045 1040 … … 1050 1045 * @return bool 1051 1046 */ 1052 public function set_path($ipath )1047 public function set_path($ipath, $clear_cache = false) 1053 1048 { 1054 1049 static $cache; 1050 if ($clear_cache) 1051 { 1052 $cache = null; 1053 return; 1054 } 1055 1055 if (!$cache) 1056 1056 { … … 1167 1167 $iri .= $this->ipath; 1168 1168 } 1169 1169 elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') 1170 1170 { 1171 1171 $iri .= $this->normalization[$this->scheme]['ipath']; … … 1211 1211 $iauthority .= $this->ihost; 1212 1212 } 1213 if ($this->port !== null)1213 if ($this->port !== null && $this->port !== 0) 1214 1214 { 1215 1215 $iauthority .= ':' . $this->port; … … 1217 1217 return $iauthority; 1218 1218 } 1219 else 1220 { 1221 return null; 1222 } 1219 1220 return null; 1223 1221 } 1224 1222 … … 1233 1231 if (is_string($iauthority)) 1234 1232 return $this->to_uri($iauthority); 1235 else 1236 1233 1234 return $iauthority; 1237 1235 } 1238 1236 }
Note: See TracChangeset
for help on using the changeset viewer.