@@ -601,11 +601,12 @@ public static function splitURI($uri) {
601601 ],
602602 ];
603603 //First step, extract the fragment
604- $ split1 = explode ( '# ' , $ uri );
604+ $ split1 = self :: _queryOrFragment ( $ uri , '# ' , ' %23 ' );
605605 $ retVal ['fragment ' ] = isset ($ split1 [1 ]) ? $ split1 [1 ] : '' ;
606606
607607 //after that, extract the query string
608- $ split2 = explode ('? ' , $ split1 [0 ]);
608+ $ split2 = self ::_queryOrFragment ($ split1 [0 ], '? ' , '%3F ' );
609+
609610 $ retVal ['query-string ' ] = isset ($ split2 [1 ]) ? $ split2 [1 ] : '' ;
610611
611612 //next comes the scheme
@@ -651,6 +652,28 @@ public static function splitURI($uri) {
651652
652653 return $ retVal ;
653654 }
655+ private static function _queryOrFragment ($ split , $ char , $ encoded ) {
656+ $ split2 = explode ($ char , $ split );
657+ $ spCount = count ($ split2 );
658+ if ($ spCount > 2 ) {
659+ $ temp = [];
660+ for ($ x = 0 ; $ x < $ spCount - 1 ; $ x ++) {
661+ $ temp [] = $ split2 [$ x ];
662+ }
663+ $ lastStr = $ split2 [$ spCount - 1 ];
664+ if (strlen ($ lastStr ) == 0 ) {
665+ $ split2 = [
666+ implode ($ encoded , $ temp ).$ encoded
667+ ];
668+ } else {
669+ $ split2 = [
670+ implode ($ encoded , $ temp ),
671+ $ split2 [$ spCount - 1 ]
672+ ];
673+ }
674+ }
675+ return $ split2 ;
676+ }
654677 /**
655678 * Validate the path part of original URI and the requested one.
656679 *
0 commit comments