Duplicate "Are you sure you want to send a form again?" Prompt

Originator:jbrayton
Number:rdar://15375938 Date Originated:1/1/2013
Status:Open Resolved:
Product:Safari on Mac OS X Product Version:Safari Version 7.0 (9537.71), OS X 10.9 (13A603)
Classification:Bug Reproducible:Always
 
Summary:
If I submit a form via an HTTP POST and then reload the resulting page, Safari displays the "Are you sure you want to send a form again?" prompt.

If I click "Send", and if the server responds to the second POST request by issuing a redirect, Safari will display the "Are you sure you want to send a form again?" prompt a second time.

Steps to Reproduce:

1.  Visit the page at:
https://secure.goldenhillsoftware.com/redirect_on_post_reload.php

2.  Click on the submit button. 

3.  Reload the resulting page.  When you click the reload button, the browser will display the "Are you sure you want to send a form again?" prompt.

4.  In response to that prompt, click the "Send" button.

5.  The server will respond to the second submission with an HTTP redirect.

Expected Results:

I would expect the browser to follow the redirect without any additional prompts.

Actual Results:

The browser follows the redirect, but displays the "Are you sure you want to send a form again?" prompt a second time.

Version:

Safari Version 7.0 (9537.71)
OS X 10.9 (13A603)

Notes:

I attached a copy of the PHP script hosted at the sample link above.

Configuration:

N/A

===

This is the code from the PHP script that I attached to the Radar submission:

<?php
	
	function show_form() {
		echo '<form method="post" action="https://secure.goldenhillsoftware.com/redirect_on_post_reload.php">';
		echo '<input type="hidden" name="ts" value="' . time() . '"/>';
		echo '<p><input type="submit"/></p>';
		echo '</form>';
	}

	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if ($_POST['ts'] == $_COOKIE['last_ts']) {
			header( 'Location: https://secure.goldenhillsoftware.com/redirect_on_post_reload.php' );
		} else {
			header('Set-Cookie: last_ts=' . $_POST['ts']);
			$COOKIE['last_ts'] = $_POST['ts'];
			echo '<p>Showing the form as the result of a POST.</p>';
			show_form();
		}
	} else {
		echo '<p>Showing the form as the result of a GET.</p>';
		show_form();
	}

?>

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!