Closed Bug 489115 Opened 15 years ago Closed 14 years ago

An empty href value in a <link rel="shortcut icon"> causes the page to be loaded twice.

Categories

(Firefox :: General, defect)

x86
Windows Vista
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 531327

People

(Reporter: vinniept, Unassigned)

Details

(Whiteboard: [CLOSEME 2010-12-01])

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; InfoPath.2)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729)

I had a bunch of php cURL POST code in the beginning of my php document and when I visited the page with Firefox I would always get a duplicate POST submission in my database because I had the following html code below:

<link rel="shortcut icon" href="" />

After I entered a value into the href the page only loaded once. I'm not aware of how the rendering behind the scenes works but this was 100% reproduceable.

Reproducible: Always

Steps to Reproduce:
1.Write some php cURL code that submits values to a form through POST
2.Below that code, start the HTML document and in the HEAD section enter <link rel="shortcut icon" href="" />
3.Finish the HTML document and visit the page
4.Examine your submissions into the form from step 1 and you should see duplicate posts
Actual Results:  
I would get duplicate records in my database.

Expected Results:  
Rendered the page once and posted only one record.
Please retest with Firefox 3.1b3 or later builds
I second this bug... it's definitely confirmed on 3.0.10.. the latest 3.0.x release.
BTW... the second page load does NOT show up in Firebug's network monitor.  It silently reloads the page when the href is missing.  

This was driving me crazy when I kept seeing multiple GETs going through my web app from one browser refresh until I looked closer and saw the missing icon link.

I removed the icon link and the multiple GETs went away.
Firefox 3.0.X doesn't matter and it will never get a fix for this issue because it will only get stability (topcrashes) and security updates.
"I had the following html code below:

<link rel="shortcut icon" href="" />"

"start the HTML document and in the HEAD section enter <link
rel="shortcut icon" href="" />"

That is not an HTML code! That is XHTML!
Hi
Today, in a support forum where I help people for php issues, I saw a weird thing:
somebody complained about a simple php script wich not behaved as expected...

the script was supposed to increment the value of a number stored in a file.
It appeared that the number was incremented twice...

I ran a large bunch of tests before I finally found the issue:
a <link rel="stylesheet" href="" /> caused firefox to make the script be executed a second time, but without refreshing the output.

It's easy to reproduce:

this code will run properly (don't forget to create compt.txt in the same directory as the script):

<?php 
  $file='compt.txt';
  $page_views=intval(file_get_contents($file));
  echo 'number in the file: '.$page_views.'<br />';
  $page_views++;
  echo 'after increment: '.$page_views.'<br />';
  file_put_contents($file, $page_views);
?>

if you refresh the page, numbers increase one by one

but this code:

<link rel="stylesheet" href="">
<?php 
  $file='compt.txt';
  $page_views=intval(file_get_contents($file));
  echo 'number in the file: '.$page_views.'<br />';
  $page_views++;
  echo 'after increment: '.$page_views.'<br />';
  file_put_contents($file, $page_views);
?>

will, when you refresh, make the numbers in the output increase 2 by 2, because the request is send to the server twice, but firefox don't refresh the output when it receive the second response.

it's the same thing for any php script... (databases insertions, session storage...)

when you encounter this bug for the first time, I guess it drives you crazy, especially if you have many codelines...

I have ran researches on the web, and find reports for this behavior since 2005...

Tested on latest firefox version, on windows and linux.
Hi!

Somebody on the forum has an explanation wich fits:

(translated from french): "Apparently, when FF tries to load the css, if href attribute is empty, it calls a default URL wich is the one of the current page, as it does for an <a> tag with empty href"

It does the same thing with an empty src attribute in a script tag. It doesn't with an empty src attribute for an img tag.

here is the link to the forum topic about this behavior (french): http://www.siteduzero.com/forum-83-499181-p2-hello-world.html
I think this might be a dupe of bug 531327?

Though if you're really seeing two *POST*s then it's likely not. Are you sure the second request isn't a GET?
Reporter, please retest with Firefox 3.6.12 or later in a fresh profile (http://support.mozilla.com/kb/Managing+profiles). Also update your plugins (flash, adobe reader, java, quicktime, silverlight, etc.) Go to the developer's website and download the latest version from there. If you no longer see this issue, please close this bug as RESOLVED, WORKSFORME. If you do see the bug, please post a comment.
Whiteboard: [CLOSEME 2010-12-01]
No reply, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
tested again with a brand new firefox 3.6.12 on windows 7


TEST 1:

simple php script:

<html>
    <head>
       <link rel="stylesheet" href="">
    </head>
    <body>
<?php 
  $file='compt.txt';
  $page_views=intval(file_get_contents($file));
  $page_views++;
  echo 'after increment: '.$page_views.'<br />';
  file_put_contents($file, $page_views);
?>
    </body>
</html>

RESULT: 

When you open then refresh several times the script, the displayed number increase 2 by 2 instead of 1 by 1. It's not the case if you remove the link tag, if you remove the href attribute or if you put something in it.


TEST 2

other test with javascript and AJAX: calling asynchronously test.php on page load with jquery. I use here the jquery load function within the alias $ function, so the js code is executed (and the script called) only when DOM is ready

script test.php (same thing):

<?php 
  $file='compt.txt';
  $page_views=intval(file_get_contents($file));
  $page_views++;
  echo 'after increment: '.$page_views.'<br />';
  file_put_contents($file, $page_views);
?>

page test.html:


<html>
	<head>
		<link rel="stylesheet" href="" />
	</head>
	<body>
	<p id="test">
	</p>
	<script type="text/javascript" src="jquery.min.js"></script>
	<script type="text/javascript">
		$(function(){
			$("#test").load("test.php");
		});
	</script>

	</body>
</html>

RESULT

the number on the screen increase 1 by 1, and if I use firebug I see only one ajax request sent. So I can guess that whatever happens, it happens before domready.

TEST 3

other test: using directly xmlhttprequest, putting the jscript before the link tag:

page.html:

<html>
	<head>
		<script type="text/javascript">

			var XHR = new XMLHttpRequest();
			XHR.onreadystatechange = function() {
			if (XHR.readyState == 4) {
				if (XHR.status == 200 || XHR.status == 0) {
				var textdoc = XHR.responseText;
				alert(textdoc);
				}	
            else {
                alert("la requête n'a pas abouti");
            }
        }
    };
    XHR.open('POST', "test.php", true);
    XHR.send(null);

		</script>
		<link rel="stylesheet" href="" />
		
	</head>
	<body>
	<p id="test">
	</p>


	</body>
</html>

RESULT:

alert messages with the number increasing 1 by 1, only one request sent on each page load. Same thing if the script is put after the link tag. Soooo... no bug at all when javascript on the page? Need a last test to check that.

TEST 4

just the same as test 1, but with a javascript alert before the link tag.

test.php:

<html>
    <head>
		<script type="text/javascript">

			alert("yeeehaaaa!");

		</script>
       <link rel="stylesheet" href="">
    </head>
    <body>
<?php 
  $file='compt.txt';
  $page_views=intval(file_get_contents($file));
  $page_views++;
  echo 'after increment: '.$page_views.'<br />';
  file_put_contents($file, $page_views);
?>
    </body>
</html>

RESULT: 

the alert is displayed only once, but the number on the screen increase 2 by 2 instead of 1 by 1. The bug is still here... but js content is not affected by it.

CONCLUSION: 
A link tag with and empty href attribute seems to make the page be loaded twice (causing php scripts being executed twice as well), but this second load doesn't make js scripts be executed again, and the call doesn't appear in firebug.

Hope that can help.

Additional note: I tested the same scripts on other browsers (latest stables opera, chrome, safari, IE), firefox is the only one with this behavior.
Hu,I hadn't seen Jonas Sicking's comment (8) but he's right, it's a duplicate of bug 531327 , and it seems to be well discussed there ^^' So maybe this one can be close definitely ^^'

@Jonas if you come here: if I understand well, the original reporter seen two POST requests, cause when called, his script was set up to make a POST via curl.

so: -> GET request to the page -> POST request via curl -> empty href cause new GET request to the script -> script executed another time -> second POST request by curl.


Hum, sorry for disturbing people posting here ^^'
Ok, sounds like a dupe of bug 531327 then.
Resolution: INCOMPLETE → DUPLICATE
You need to log in before you can comment on or make changes to this bug.