Empty "Title" field in entry causes errors.

Found a bug? Tell us!!
Post Reply
Brendon K
Regular
Posts: 44
Joined: Thu Feb 23, 2006 10:35 pm
Location: Saratoga Springs, NY, USA
Contact:

Empty "Title" field in entry causes errors.

Post by Brendon K »

I made sure to update to v1.0.1 to be certain the bug(s) still exist in the current version.

1.) The default theme for v1.0.1 breaks if no title is supplied for an entry. I've seen some themes supply a default title if none are supplied, this might be a possible fix for the theme.

2.) When attempting to edit the entries, PHP throws a warning of "Invalid argument supplied for foreach() in <base>/include/functions.inc.php on line 252".

...and that warning/error also screws up the HTML on the admin page; though I'm sure you're not too worried about that. ;)
They say, "Practice makes perfect," yet they also say, "Nobody's perfect." I don't get it.
Brendon K
Regular
Posts: 44
Joined: Thu Feb 23, 2006 10:35 pm
Location: Saratoga Springs, NY, USA
Contact:

Post by Brendon K »

...also somewhat unrelated, but still a noticed bug, the following post entry (for a test I need for creating a new plugin) attempts to render the code as HTML, I believe...

Code: Select all

<textarea name="code" class="php" cols="60" rows="10">
<?php
    echo 'hello world';
?>
</textarea>

<pre class="php">
<?php
    echo 'hello world';
?>
</pre>
I think it may be a problem with nl2br for people that don't use the rich text editor.
They say, "Practice makes perfect," yet they also say, "Nobody's perfect." I don't get it.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Can you describe how it breaks the default template? I'm sure Carl would like to know.

To display code properly, you need to escape the <> as < and >. Otherwise it's ignored.

I think.
Judebert
---
Website | Wishlist | PayPal
Brendon K
Regular
Posts: 44
Joined: Thu Feb 23, 2006 10:35 pm
Location: Saratoga Springs, NY, USA
Contact:

Post by Brendon K »

I tested this a bit more thoroughly. I apologize for not replying sooner, I help out on technical forums and I always hate people that post a bug and then disappear. I had the problem installed on my development machine and hadn't turned it on in awhile, so my apologies.

It apparently isn't (just) the title that's causing the template breakage, although for some reason, adding one fixes the rendering.

Images:
1 - Entry with title and problem body
http://img.photobucket.com/albums/v379/ ... m_text.gif

2 - Entry without title, and problem body included
http://img.photobucket.com/albums/v379/ ... _error.gif

3 - Entry without title, simple body text
http://img.photobucket.com/albums/v379/ ... _title.gif

4 - Administration error I'm getting (the entries to edit/delete is below the main content, outside the box border):
http://img.photobucket.com/albums/v379/ ... /admin.gif
The pretty color-coded error message and debug trace is from my Xdebug module, in case you're not familiar with it.

PHP v5.1.6, MySQL v5.0.19-nt, Apache v2.2.3
Problem body text:
<textarea name="code" class="php" cols="60" rows="10">
<?php
echo 'hello world';
?>
</textarea>

<pre class="php">
<?php
echo 'hello world';
?>
</pre>

\n\n
If anymore information is desired, let me know...hmmm, the forum style isn't too conducive to image posting. Perhaps I should just link to them? (Edit, linked) :P
They say, "Practice makes perfect," yet they also say, "Nobody's perfect." I don't get it.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Images aren't bad, as long as they aren't wider than the forum width.

I really don't like fixed-width styles for exactly this reason. But everyone else seems to adore them, so I suffer bravely for the good of the community...

Thanks for the extra debugging. It's quite thorough, and I'm sure Carl will have a thing or two to say as soon as he gets to this thread.

1 - I think the problem text would be fixed if we escaped the <?php> as <?php> instead. We try to be very careful with security, so we don't allow arbitrary PHP in entries. It wouldn't surprise me if Garvin actually does some checking. (The <br />s at the end come from the NL2BR plugin.)

2 - Whoa. That's bad. Looks like the missing title has allowed the <?php> tag to be interpreted. Carl knows how to supply a default title in the template, and we'll get it committed as soon as Carl fixes it.

3 - That's more what I was expecting. Again, as soon as it's fixed, we'll commit it.

4 - That problem occurs when there are no categories, I believe. Make at least one category and it should go away.

Glad to see you came back. Actually, with Garvin gone, I'm having trouble keeping up with the forum. You came back in good time, as far as I'm concerned. Besides, my only pet peeves are people who open problems and never look at them again -- ever, and people who give up at the slightest hint of difficulty. You don't fall in either category. 8)
Judebert
---
Website | Wishlist | PayPal
Brendon K
Regular
Posts: 44
Joined: Thu Feb 23, 2006 10:35 pm
Location: Saratoga Springs, NY, USA
Contact:

Post by Brendon K »

I checked the source code of my entry where you thought the <?php was being rendered... When I first noticed this error (and hadn't yet reported it, thinking I did something wrong), I thought that too. I had forgotten though that the source code showed it had not truly been rendered. All I can assume is that the browser thinks it's a tag, and this is why:

With the NL2BR plugin turned on, the newline applied after the <?php adds a <br /> directly after the PHP tag, so it looks like this:
<?php<br />

...would the browser think it's all one tag? Perhaps, let's see...removing the newline...

OH! Apparently Carl is grabbing way too much content of the story for a title when no title is applied! I viewed the source of my entry and was confused as to why there were not just two <?php, but 4...and scratched me head. Because it cuts off the content at a certain length, the tags are incomplete and messes up the rendering (I think).

Carl can play around a bit more and understand this a lot more than I could. With the example body, I think it'll help...hmm, a bit more testing, I'm still befuddled but think I might be on the right track. Like I said though, Carl would be much better off figuring something like this out.

Thanks for the assistance, judebert! I hope Garvin enjoys his time off, he definately deserves it and thensome.
They say, "Practice makes perfect," yet they also say, "Nobody's perfect." I don't get it.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Well, you could go to templates/default/entries.tpl -- make a backup first -- and find this line:

Code: Select all

<h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>
Then change it to:

Code: Select all

<h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title|@default:"Untitled Entry"}</a></h4>
Judebert
---
Website | Wishlist | PayPal
Post Reply