Wim
Wim

Reputation: 11252

Strange PHP output corruption

I'm having a very strange output corruption on one of my PHP sites. Sometimes, a piece of HTML code is displayed, rather than the tags being interpreted. It looks like some characters are missing, messing up the tags. See the example below: the second line should just be a link to c1, but due to some reason part of the target URL is shown.

alt text http://trappist.elis.ugent.be/~wheirman/atuin/tmp/phpstrangeness.png

The problem is temporary, a refresh usually solves it. This can happen on different parts of the page (although often in the same location). Only Safari seems affected (but I'm suspecting Firefox just masks the problem due to more tolerant parsing). It happens on both my development server as the live one, they both have slightly different settings (output buffering, chunked transfer), although the probability of it happening seems to vary.

Anyone ever seen something like this??

EDIT

When I "View Source" in Safari on this page, I get the following HTML:

<tr class="odd">
  <td>73</td>
  <td><a href="companies.php?view=1&amp;companyid=73&amp;return=%2Foffice%2Fcompanies.php">c1</a></td>
  <td></td>
  <td><img src='/images/dot_blue.png'  class="altTooltip" alt="inactive: no account"  /> </td>

I can't see anything wrong with this, so either Safari has reloaded the page when I asked it for the source, or I'm not looking hard enough...

Upvotes: 4

Views: 345

Answers (3)

Wim
Wim

Reputation: 11252

I finally found the problem (using Web Inspector): TinyMCE has been inserting tags (which it uses to load language files and extension modules), at seemingly random places inside my own HTML. The result was that, in the case visible from my screenshot, something like <a href="foo<script src="tinymce/lang/en.js">bar.php">foobar</a>.

Since I'm also using jQuery on the same page, my guess is it was ultimately cause by jQuery's modifications to the DOM and TinyMCE's additions happening at the same time which resulted in some sort of race condition (caused by a bug that only appears to exhibit itself in Safari).

I am now using the jQuery build of TinyMCE, and all has been well since...

Thanks to everyone for the help!

Upvotes: 1

J. Martin
J. Martin

Reputation: 1737

When you select a piece of HTML and view source, what you get is not 100% what is there. For instance, all of you &'s are &amp;, which probably means you selected the offending text and viewed the selection's source.

If you are still having the issue, trying viewing the whole source code without selecting anything, and then using ctrl + f to find the spot in the code, and try and give us a larger sample, not just the offending row, but a correct row, and in a larger context.

For instance, when using tables, a mislaid <td> can have very weird consequences, this doesn't look like that type of issue, I am just saying that we need context to be able to help.

There's also the issue that some browsers, in order to view source, actually resubmit the page and get a second copy of it. I have a feeling that it is the code that's outputting the text, so look and see if you are using something like

<?= $someVar ?>

and make sure it's not like this:

<a href=<?= isset($x) ?'"'. $someVar.'"': '"'.$someOlderVar.'">'?>> xxx </a>

So, no selecty, and bigger sample please. And we'd prolly need something from the code that outputs the errored HTML...

Upvotes: 1

Thomas
Thomas

Reputation: 181745

Well, here's my shot in the dark.

The break occurs in the word "office", after the fi character combination. I would bet that the fi ligature is -- somehow -- causing trouble.

How exactly? Since that HTML code doesn't contain the ligature character, this might be a bug in Safari. Especially since it occurs randomly. Could you try to rename that file, and see if the problem goes away?

Having valid HTML might also help in avoiding this problem, because it makes parsing easier.

Upvotes: 2

Related Questions