@@ -258,11 +258,11 @@ private function hrefLangsForEntry(Entry $entry): array
258258 ->filter (fn (Site $ site ) => $ entry ->in ($ site ->handle ())->published ())
259259 ->reject (fn (Site $ site ) => collect (config ('statamic.seo-pro.alternate_locales.excluded_sites ' ))->contains ($ site ->handle ()))
260260 ->map (fn (Site $ site ) => [
261- 'href ' => $ entry ->in ($ site ->handle ())->absoluteUrl (),
261+ 'href ' => $ this -> sanitizeUrl ( $ entry ->in ($ site ->handle ())->absoluteUrl () ),
262262 'hreflang ' => strtolower (str_replace ('_ ' , '- ' , $ site ->locale ())),
263263 ])
264264 ->push ([
265- 'href ' => $ entry ->root ()->absoluteUrl (),
265+ 'href ' => $ this -> sanitizeUrl ( $ entry ->root ()->absoluteUrl () ),
266266 'hreflang ' => 'x-default ' ,
267267 ])
268268 ->all ();
@@ -274,13 +274,18 @@ private function hrefLangsForTerm(Term $term): array
274274 ->values ()
275275 ->reject (fn (Site $ site ) => collect (config ('statamic.seo-pro.alternate_locales.excluded_sites ' ))->contains ($ site ->handle ()))
276276 ->map (fn (Site $ site ) => [
277- 'href ' => $ term ->in ($ site ->handle ())->absoluteUrl (),
277+ 'href ' => $ this -> sanitizeUrl ( $ term ->in ($ site ->handle ())->absoluteUrl () ),
278278 'hreflang ' => strtolower (str_replace ('_ ' , '- ' , $ site ->locale ())),
279279 ])
280280 ->push ([
281- 'href ' => $ term ->inDefaultLocale ()->absoluteUrl (),
281+ 'href ' => $ this -> sanitizeUrl ( $ term ->inDefaultLocale ()->absoluteUrl () ),
282282 'hreflang ' => 'x-default ' ,
283283 ])
284284 ->all ();
285285 }
286+
287+ private function sanitizeUrl (string $ url ): string
288+ {
289+ return htmlspecialchars ($ url , ENT_QUOTES | ENT_XML1 , 'UTF-8 ' );
290+ }
286291}
0 commit comments