Author: Shivam Mathur (shivammathur)
Committer: Derick Rethans (derickr)
Date: 2026-06-24T17:07:57+01:00

Commit: 
https://github.com/php/web-php/commit/7642d16b9b9b592be5cceac306df0f78dffd5bae
Raw diff: 
https://github.com/php/web-php/commit/7642d16b9b9b592be5cceac306df0f78dffd5bae.diff

Fix preserving query strings for error page redirects

Changed paths:
  M  error.php


Diff:

diff --git a/error.php b/error.php
index 3feda731ca..5cc70996a9 100644
--- a/error.php
+++ b/error.php
@@ -19,7 +19,9 @@
 // Get URI for this request, strip leading slash
 // See langchooser.inc for more info on STRIPPED_URI
 $URI = substr($_SERVER['STRIPPED_URI'], 1);
-$queryString = $_SERVER['QUERY_STRING'] ?? '';
+$uriParts = explode('?', $URI, 2);
+$URI = $uriParts[0];
+$queryString = isset($uriParts[1]) ? html_entity_decode($uriParts[1], 
ENT_QUOTES, 'UTF-8') : '';
 
 // ============================================================================
 // Mozilla Search Sidebar plugin resource file handling (need to be mirror
@@ -38,8 +40,8 @@
 
 // ============================================================================
 // BC: handle bugs.php moved completely to bugs.php.net
-if (preg_match("!^bugs.php\\?(.+)$!", $URI, $array)) {
-    mirror_redirect("https://bugs.php.net/?$array[1]";);
+if ($URI === 'bugs.php' && $queryString !== '') {
+    mirror_redirect("https://bugs.php.net/?$queryString";);
 }
 
 // ============================================================================

Reply via email to