Skip to content

Commit a2bdefa

Browse files
author
Joseph Lenton
committed
JosephLenton#28 now check if QUERY_STRING is set
It seems on some versions the query string is not set at all, so I have added an 'isset', which fix a bug when it's not provided.
1 parent 831a359 commit a2bdefa

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/php_error.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,12 +3039,28 @@ private function displayJSInjection() {
30393039
* This outputs the error details in HTML.
30403040
*/
30413041
private function displayError( $message, $errLine, $errFile, $errFileType, $stackTrace, &$fileLinesSets, $numFileLines, $dumpInfo ) {
3042-
$applicationRoot = $this->applicationRoot;
3043-
$serverName = $this->serverName;
3044-
$backgroundText = $this->backgroundText;
3045-
$requestUrl = str_replace( $_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI'] );
3042+
$applicationRoot = $this->applicationRoot;
3043+
$serverName = $this->serverName;
3044+
$backgroundText = $this->backgroundText;
30463045
$displayLineNumber = $this->displayLineNumber;
30473046

3047+
/*
3048+
* When a query string is not provided,
3049+
* in some versions it's a blank string,
3050+
* whilst in others it's not set at all.
3051+
*/
3052+
if ( isset($_SERVER['QUERY_STRING']) ) {
3053+
$requestUrl = str_replace( $_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI'] );
3054+
$requestUrlLen = strlen( $requestUrl );
3055+
3056+
// remove the '?' if it's there (I suspect it isn't always, but don't take my word for it!)
3057+
if ( $requestUrlLen > 0 && substr($requestUrl, $requestUrlLen-1) === '?' ) {
3058+
$requestUrl = substr( $requestUrl, 0, $requestUrlLen-1 );
3059+
}
3060+
} else {
3061+
$requestUrl = $_SERVER['REQUEST_URI'];
3062+
}
3063+
30483064
$this->displayHTML(
30493065
// pre, in the head
30503066
function() use( $message, $errFile, $errLine ) {

0 commit comments

Comments
 (0)