@@ -48,22 +48,35 @@ public function render(): string
4848
4949 $ viewData = $ this ->arguments ['viewData ' ];
5050
51- // UriBuilder does not properly encode specified entities in URL parameter
52- // For more details, please see the following TYPO3 issue https://forge.typo3.org/issues/107026
53- if (isset ($ viewData ['requestData ' ]['id ' ]) && GeneralUtility::isValidUrl ($ viewData ['requestData ' ]['id ' ])) {
54- $ viewData ['requestData ' ]['id ' ] = str_replace ("%2F " , "%252F " , $ viewData ['requestData ' ]['id ' ]);
55- }
56-
57- $ arguments = [];
58- foreach ($ viewData ['requestData ' ] as $ key => $ value ) {
59- if (!in_array ($ key , $ this ->arguments ['excludedParams ' ])) {
60- $ arguments ['tx_dlf ' ][$ key ] = $ value ;
51+ $ dlfArguments = [];
52+ foreach ($ viewData ['requestData ' ] as $ key => $ data ) {
53+ if (is_array ($ data )) {
54+ $ tempData = [];
55+ foreach ($ data as $ dataKey => $ dataValue ) {
56+ if (!in_array ($ key . '[ ' . $ dataKey . '] ' , $ this ->arguments ['excludedParams ' ])) {
57+ $ tempData [] = $ dataValue ;
58+ }
59+ }
60+ if (count ($ tempData ) > 0 ) {
61+ $ dlfArguments [$ key ] = $ tempData ;
62+ }
63+ } elseif (!in_array ($ key , $ this ->arguments ['excludedParams ' ])) {
64+ $ dlfArguments [$ key ] = $ data ;
6165 }
6266 }
6367
6468 $ additionalParams = $ this ->arguments ['additionalParams ' ];
6569 foreach ($ additionalParams as $ key => $ value ) {
66- $ arguments ['tx_dlf ' ][$ key ] = $ value ;
70+ $ dlfArguments [$ key ] = $ value ;
71+ }
72+
73+ // double replace encoding in URL value parameters
74+ if (isset ($ dlfArguments ['id ' ])) {
75+ $ dlfArguments ['id ' ] = $ this ->doubleEncode ($ dlfArguments ['id ' ]);
76+ }
77+
78+ if (isset ($ dlfArguments ['multiViewSource ' ]) && is_array ($ dlfArguments ['multiViewSource ' ])) {
79+ $ dlfArguments ['multiViewSource ' ] = array_map ([$ this , 'doubleEncode ' ], $ dlfArguments ['multiViewSource ' ]);
6780 }
6881
6982 $ childContent = (string ) $ this ->renderChildren ();
@@ -77,7 +90,7 @@ public function render(): string
7790 }
7891
7992 $ uri = $ uriBuilder
80- ->setArguments ($ arguments )
93+ ->setArguments ([ ' tx_dlf ' => $ dlfArguments ] )
8194 ->setArgumentPrefix ('tx_dlf ' )
8295 ->uriFor ('main ' );
8396
@@ -92,4 +105,21 @@ public function render(): string
92105
93106 return $ tag ->tag ->render ();
94107 }
108+
109+ /**
110+ * Double encode specific characters in URL.
111+ *
112+ * UriBuilder does not properly encode specified entities in URL parameter
113+ * For more details, please see the following TYPO3 issue https://forge.typo3.org/issues/107026
114+ *
115+ * @param string $url The URL in which specific characters should be encoded
116+ * @return string The replaced URL
117+ */
118+ private function doubleEncode (string $ url ): string
119+ {
120+ if (GeneralUtility::isValidUrl ($ url )) {
121+ $ url = str_replace ("%2F " , "%252F " , $ url );
122+ }
123+ return $ url ;
124+ }
95125}
0 commit comments