Firefox reloads pages when automatically changing encodings

Bug #264551 reported by José M. López-Cepero
6
Affects Status Importance Assigned to Milestone
firefox (Ubuntu)
Invalid
Undecided
Unassigned
firefox-3.0 (Ubuntu)
Invalid
Low
Unassigned

Bug Description

Binary package hint: firefox

Firefox detects the appropriate encoding of a webpage which does not explicitly state it and reloads it to re-render the page with the correct encoding if necessary.

Unfortunately, this completely disregards the fact that reloading a dynamic page may have unintended consequences. Specifically, Firefox will happily reload a page which has a GET parameter, which means that some operations (eg. a database insert) may end up being done twice.

I have built a case which reliably reproduces the bug in my machine. I have hosted it at:

http://andvaranaut.es/example.php

The file is a PHP script which does the following:

1) Writes a very basic html header, with no encoding info (the reload event happens even if the output is plain text, by the way)
2) Writes "Hi, I'm gonna output some weird characters in about 2 secs"
3) Sleeps for 2 secs
4) Writes a bunch of accented letters to stdout (in UTF-8, although the exact encoding seems to be irrelevant).
5) Sleeps for another 2 secs
6) Writes "Got that?", closes the remaining HTML tags, and ends

Each of the writings in steps 2, 4 and 6 is done within a paragraph tag, although that does not seem relevant to triggering the reload.

The very first time you visit the page, you'll get to stage 2) (see the "Hi, I'm gonna output..." message). Then, the browser will pause for 2 seconds (stage 3)). And then, the page will immediately reload. The reason is that, having received the accented letters in stage 4), Firefox decides that it has to rerender the page, and does so by reloading and internally setting what it considers to be a suitable encoding this time. Once the reload begins, you will proceed through steps 1)-6) as expected. This means that you will wait for 6 seconds instead of 4, that the "Hi, I'm gonna output..." message will flash twice, and that all PHP code in steps 1) through 3) will be executed twice at the end of the day.

If you hit F5 and/or press Enter in the address bar, Firefox will remember the encoding it used and only load the page once, working as expected. But, if you open a new session, hit Shift+F5 or add some random GET parameters to the URL, the page will again load twice. (If you repeat GET parameters in the same session, it also remembers the encoding. But you have to repeat the full URL).

I have not tested what happens with POST requests, where the results may be even more disastrous (either a form will be submitted twice, or the user will be shown a confusing dialog about "refreshing" a page he is just visiting, or, worse yet, the page will reload without sending the form contents a second time).

I'm using Firefox 3.0.1 in amd64 Hardy, fully updated.

Revision history for this message
Andreas Moog (ampelbein) wrote : Reassigning issue to firefox-3

Thank you for your bugreport. Since this seems to be an issue with
version 3 of the firefox browser, I'm reassigning the package.

 affects ubuntu/firefox
 status invalid

 affects ubuntu/firefox-3.0
 status new

Changed in firefox:
status: New → Invalid
Revision history for this message
Pedro Villavicencio (pedro) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Thanks in advance.

Changed in firefox-3.0:
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Andreas Moog (ampelbein) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!

Changed in firefox-3.0 (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.