com web/bugs: Exit script execution directly in redirect(): include/functions.php www/bug.php www/error.php www/fix.php www/index.php www/login.php
www/patch-add.php www/report.php www/vote.php

From: Date: Wed, 06 Aug 2014 08:14:08 +0000
Subject: com web/bugs: Exit script execution directly in redirect(): include/functions.php www/bug.php www/error.php www/fix.php www/index.php www/login.php
www/patch-add.php www/report.php www/vote.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-19643@lists.php.net to get a copy of this message
Commit: 1de55b7a5dd34d518256b2d6632e637cfb225c9f Author: Sobak <msobaczewski@gmail.com> Wed, 6 Aug 2014 10:14:08 +0200 Parents: 100a35d3e67996b85d910fa817b0599197aae00c Branches: master Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=1de55b7a5dd34d518256b2d6632e637cfb225c9f Log: Exit script execution directly in redirect() Changed paths: M include/functions.php M www/bug.php M www/error.php M www/fix.php M www/index.php M www/login..php M www/patch-add.php M www/report.php M www/vote.php Diff: diff --git a/include/functions.php b/include/functions.php index b708420..9995d4a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1824,6 +1824,7 @@ function response_footer($extra_html = '') function redirect($url) { header("Location: {$url}"); + exit; } diff --git a/www/bug.php b/www/bug.php index bc8e1a6..bc85fd1 100644 --- a/www/bug.php +++ b/www/bug.php @@ -1,7 +1,9 @@ <?php - /* User interface for viewing and editing bug details */ +// Obtain common includes +require_once '../include/prepend.php'; + // Start session session_start(); @@ -15,14 +17,12 @@ if (isset($_REQUEST['id']) && $_REQUEST['id'] == 'preview') { $bug['assign'] = ''; if (!$bug) { - header('Location: index.php'); - exit; + redirect('index.php'); } } else { // Bailout early if no/invalid bug id is passed if (empty($_REQUEST['id']) || !((int) $_REQUEST['id'])) { - header('Location: index.php'); - exit; + redirect('index.php'); } else { $bug_id = (int) $_REQUEST['id']; } @@ -31,9 +31,6 @@ if (isset($_REQUEST['id']) && $_REQUEST['id'] == 'preview') { // Init common variables $errors = array(); -// Obtain common includes -require_once '../include/prepend.php'; - // Set edit mode $edit = isset($_REQUEST['edit']) ? (int) $_REQUEST['edit'] : 0; @@ -51,7 +48,6 @@ if (isset($_GET['unsubscribe'])) { if (!$hash) { redirect("bug.php?id={$bug_id}"); - exit; } unsubscribe($bug_id, $hash); $_GET['thanks'] = 9; @@ -91,7 +87,6 @@ if (isset($_POST['subscribe_to_bug']) || isset($_POST['unsubscribe_to_bug'])) { $thanks = 7; } redirect("bug.php?id={$bug_id}&thanks={$thanks}"); - exit; } } // If we get here, display errors @@ -111,7 +106,6 @@ if ($edit == 1 && $is_trusted_developer && isset($_GET['delete_comment'])) { $addon = '&thanks=1'; } redirect("bug.php?id=$bug_id&edit=1$addon"); - exit; } // captcha is not necessary if the user is logged in @@ -548,7 +542,6 @@ if (isset($_POST['ncomment']) && !isset($_POST['preview']) && $edit == 3) { if (isset($_POST['in']) && !isset($_POST['preview']) && !$errors) { mail_bug_updates($bug, $_POST['in'], $from, $ncomment, $edit, $bug_id); redirect("bug.php?id=$bug_id&thanks=$edit"); - exit; } switch (txfield('bug_type', $bug, isset($_POST['in']) ? $_POST['in'] : null)) diff --git a/www/error.php b/www/error.php index 981b742..b6a66af 100644 --- a/www/error..php +++ b/www/error.php @@ -9,7 +9,6 @@ require_once '../include/prepend.php'; $id = !empty($_GET['id']) ? (int) $_GET['id'] : 0; if ($id) { redirect("bug.php?id={$id}"); - exit; } response_header('Bugs :: 404 Not Found'); diff --git a/www/fix.php b/www/fix.php index 17d79f2..7bce681 100644 --- a/www/fix.php +++ b/www/fix.php @@ -1,17 +1,15 @@ <?php - /* Admin interface for closing bug reports via direct link */ +// Obtain common includes +require_once '../include/prepend.php'; + $bug_id = (int) $_REQUEST['id']; if (!$bug_id) { - header('Location: index.php'); - exit; + redirect('index.php'); } -// Obtain common includes -require_once '../include/prepend.php'; - // fetch info about the bug into $bug $bug = bugs_get_bug($bug_id); @@ -112,8 +110,7 @@ $ncomment = $qftext . (!empty($ncomment) ? "\n\n".$ncomment : ""); // If the report already has the status of the resolution, bounce over to the main bug form // which shows the appropriate error message. if ($status == $bug['status']) { - header("Location: bug.php?id={$bug_id}&edit=1&in[resolve]={$reason}"); - exit; + redirect("bug.php?id={$bug_id}&edit=1&in[resolve]={$reason}"); } // Standard items @@ -164,7 +161,6 @@ if (!PEAR::isError($res) && !empty($ncomment)) { if (!PEAR::isError($res)) { mail_bug_updates($bug, $in, $auth_user->email, $ncomment); redirect("bug.php?id={$bug_id}&thanks=1"); - exit; } // If we end up here, something went wrong. diff --git a/www/index.php b/www/index.php index 9b616bd..54c2aa0 100644 --- a/www/index.php +++ b/www/index.php @@ -11,7 +11,6 @@ require_once '../include/prepend.php'; $id = !empty($_GET['id']) ? (int) $_GET['id'] : 0; if ($id) { redirect("bug.php?id={$id}"); - exit; } if($_SERVER['REQUEST_URI'] == '/random') { @@ -20,7 +19,6 @@ if($_SERVER['REQUEST_URI'] == '/random') { $result = $dbh->prepare($query)->execute(); $id = $result->fetchRow(); redirect("bug.php?id={$id[0]}"); - exit; } response_header('Bugs'); diff --git a/www/login.php b/www/login.php index adaa3b3..ee0f0f8 100644 --- a/www/login.php +++ b/www/login.php @@ -5,8 +5,7 @@ session_start(); require_once '../include/prepend.php'; if (!empty($_SESSION['user'])) { - header('location: index.php'); - exit; + redirect('location: index.php'); } response_header('Login'); @@ -19,11 +18,9 @@ if (isset($_POST['user'])) { if ($logged_in === 'developer') { if (!empty($_POST['referer']) && preg_match("/^{$site_method}:\/\/". preg_quote($site_url) .'/i', $referer)) { - header('location: '. $referer); - exit; + redirect($referer); } - header('location: index.php'); - exit; + redirect('index.php'); } else { ?> <div style="background: #AB1616; padding: 3px; width: 300px; color: #FFF; margin: 3px;">Wrong username or password!</div> diff --git a/www/patch-add.php b/www/patch-add.php index bbe6808..ad546a1 100644 --- a/www/patch-add.php +++ b/www/patch-add.php @@ -104,7 +104,6 @@ if (isset($_POST['addpatch'])) { } redirect("patch-display.php?bug={$bug_id}&patch={$patch_name_url}&revision={$e}"); - exit; } catch (Exception $e) { $patches = $patchinfo->listPatches($bug_id); include "{$ROOT_DIR}/templates/addpatch.php"; diff --git a/www/report.php b/www/report.php index 80a0237..a36397a 100644 --- a/www/report.php +++ b/www/report.php @@ -181,7 +181,6 @@ OUTPUT; $_SESSION['bug_preview']['ldesc'] = $fdesc; $_SESSION['captcha'] = $_POST['captcha']; redirect('bug.php?id=preview'); - exit; } $res = $dbh->prepare(' @@ -315,10 +314,8 @@ REPORT; $patchname = urlencode($_POST['in']['patchname']); $patchemail= urlencode($_POST['in']['email']); redirect("patch-add.php?bug_id={$cid}&patchname={$patchname}&email={$patchemail}"); - exit; } redirect("bug.php?id={$cid}&thanks=4"); - exit; } } else { // had errors... diff --git a/www/vote.php b/www/vote.php index d3e0694..12d2ac5 100644 --- a/www/vote.php +++ b/www/vote.php @@ -68,5 +68,4 @@ $dbh->prepare(" )->execute(); // redirect to the bug page (which will display the success message) -header("Location: bug.php?id=$id&thanks=6"); -exit; +redirect("bug.php?id=$id&thanks=6");

« previous php.webmaster (#19643) next »