Invalid HTML causing blank pages?

Invalid HTML causing blank pages?

by Enrique Castro -
Number of replies: 4
Picture of Core developers Picture of Particularly helpful Moodlers
Hi,
   Here at the ULPGC Virtual Campus site we are experiencing an annoying problem, that may be related to the HTML editor (or may be not).

Sometimes, after creating/editing some text in the HTML editor, we get blank pages for the activities involved. The problem arises when editing the "description" or similar field for an assigment, or diary  or resource etc. When the teacher press the "save changes" button, Moodle tries to display teh new page, present the header and then stops, no further information in the page. The footer is not printed .

In one event, the problem happened in a Dialoge, when a student sent a message to the theacher, all users with messages got blank pages when accesing the Dialogue (users that never had sent/received a message could see the Dialogue page correctly)

The support guys corrected the problem by accessing the database through phpMyAdmin and deleting some <br /> tags  at the end of the "problematic" texts. This was just serendipity, corrected the problem but we don't know why.

I suppose this has something to do with a block of HTML text that, been valid in itself, becomes invalid when inserted within the HTML stream of a Moodle page, but I do not know HTML enough to see how and when this will happen.

I would like to know if this is a bug in the editor or other part of Moodle (and try to fix it).
If we would know what precise combination triggers the problem I could warn my users not to use some constructs.

Any ideas will be welcome

- Enrique Castro -
Average of ratings: -
In reply to Enrique Castro

Re: Invalid HTML causing blank pages?

by Enrique Castro -
Picture of Core developers Picture of Particularly helpful Moodlers

We do not know the precise cause, but commenting out this line on /moodle/lib/weblib.php, function text_to_html, resolves the problem:

    // $text = eregi_replace(">(:space:+)<", "><", $text);

We have not seen again this "bug" since this line was commented out. There are not apparent drawbacks in not "cleaning" that white space.

- Enrique -
In reply to Enrique Castro

Re: Invalid HTML causing blank pages?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hmm, removing or adding white space should not affect the rendering of a web page ... it maybe that something else has happened instead ...
In reply to Martin Dougiamas

Re: Invalid HTML causing blank pages?

by Enrique Castro -
Picture of Core developers Picture of Particularly helpful Moodlers
Hi Martin,
    You are right, and that's probably the reason why disabling this call to function eregi_replace() doesn't bite in another form and can be used to avoid the problem.

The function is doing something more than cleaning white space. I wonder that this function fails (and produce invalid HTML text) when there are "LF" or "CR" , or other "control code" characters in the cleaned text.  In occasions, we see broken lines due to ghost LFs in the code (they are not seen in the HTML editor, or rather are seen as a space. But if you delete that space and enter a new one with spacebar, the line is then "continuous" again).

The original problem was solved by deleting an ending  <br /> tag in the database-stored text. I wonder if this <br /> come from those control codes, and should not be there.

- Enrique -




In reply to Enrique Castro

Re: Invalid HTML causing blank pages?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Can you please attach a text file containing some original source text that was causing the problem for you?  That would help us test it out!