Public bug reported:

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.

** Affects: firefox (Ubuntu)
     Importance: Undecided
         Status: New

-- 
Firefox reloads pages when automatically changing encodings
https://bugs.launchpad.net/bugs/264551
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to