Ask your Symfony questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Why does the HTML sometimes become visible? Symfony


We face an irritating problem, both on this site and over on our [[LINK href=""]]WordPress[[/LINK]] site. Both are built with Symfony 1.2.5. Sometimes the HTML becomes visible. I've seen this happen once myself, and I've gotten some reports of it from our users. For instance, Antoine Leclercq wrote to us (quoted with permission):

<blockquote>Quick feedback, I'm getting some strange errors sometimes; some html tags randomly look broken :

[[LINK href="[email protected]/4384888515/"]][email protected]/4384888515/[[/LINK]]

This happened when I tried to login (and missed that you were asking for a username instead of the email). Btw I would advise you to accept the email also as a username</blockquote>

He was kind enough to send us a screen shot, which I'm uploading. Sometimes the HTML which should be invisible becomes visible. Usually it is the second half of some HTML tag that becomes visible. For instance, we may have an HTML tag that looks like this:

<li class="selected"><span class="step-number-active">1</span> Ask a Question</li>

Normally the HTML itself would not appear in the browser, but rather, the browser would turn this into a link, and only the text "Ask a Question" would be visible. But sometimes one will see the second half of the HTML:

class="step-number-active">1</span> Ask a Question</li>

And then the link doesn't work, since the HTML is malformed.

The problem is very intermittent - its likely that you yourself have not seen this problem. The problem is highly transitory, in the sense that if you do the see the problem, then to make it go away, all you have to do is hit the Refresh button. It almost never happens twice in a row.

The problem has been reported in both FireFox and Google Chrome.

I've been trying to think of what could cause this. A problem with cache? No, that would serve an old copy of the page, but not a mal-formed copy.

What then?

Answers (4)


michalg answers:


First, you could exclude that it isn't apache (or whatever server you use) / network problem. Maybe packets get malformed.

Try putting some static html page on your server and write some simple script on other server/computer, which will download this page couple (couple of hundreds) times and everytime it will calculate md5sum. If md5sum will be wrong, this means that you don't have problem with symfony or php.

Also, you could use same technique for testing symfony & php - this way you could try loading various pages (and save every time it's wrong) and see what exactly is malformed(thanks to saved page source) and where (at what tags, what component, slot). Maybe you will find some pattern which is repeated.

michalg comments:

I've written small program (launched from command line) in hope to repeat Antoine's situation (with wrong login).

It should log every response that it's different from first one.

$url = "";
$md5 = null;

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_POST, true);

$post = array("signin[username]"=>"test");
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

for($i = 0; $i < 1000; $i++) {
$page = curl_exec($ch);

if ($md5 == null) {
$md5 = md5($page);
file_put_contents("page.".$i, $page);

if ($md5 != md5($page)) {
file_put_contents("page.".$i, $page);
echo "E";
} else {
echo ".";

I couldn't manage to get an error (stopped after about 500 tries). So either:
- i didn't test it enough times
- you need to open couple of pages in some order
- you need to have something in session

Or (IMHO less possible):
- it's related to browser / javascript
- it's happens because of some gateway which i don't use to connect to your server

Btw, maybe you should upgrade to symfony 1.2.12 ?

Lawrence Krubner comments:

Michal, thank you, this is a useful script for us to test with.


Daniel Lohse answers:

You know, look at the attached screenshot.

Which means that there are sometimes script tags in your source or, more precisely, in your form's "method" attribute where they shouldn't be.

Lawrence Krubner comments:

Can you think of any reason why this would happen? Why would a script tag suddenly appear in the middle of another tag? And then, if you hit refresh, why would it disappear? What would cause this to happen in a temporary, transitory way?

Thanks much for the screen shot.

Lawrence Krubner comments:

Here is the actual source code for the form that is showing an error in your screen shot:

<form id="user_finance_action" action="<?php echo url_for('user/withdraw'); ?>" method="post" name="frm_mytransfer">

<p>Withdraw cash to PayPal? ($ amount) <input class="user_finance field" type="text" name="amount" /> <input class="user_finance2" type="submit" value="Withdraw Cash" name="sbt_mytransfer"/></p>


Now why would a script tag suddenly appear in the middle of that?

Daniel Lohse comments:

I have no idea, this is really strange and a problem I haven't seen before. Updating to 1.2.12 (or 1.3 for that matter) would nevertheless be a good thing.

Do you have any additional filters that could change the response before it's sent?

Daniel Lohse comments:

Here's one more screenshot which shows the severity of this problem. :(