Comment subject is calculated incorrectly when the comment text contains only HTML tags

doq - April 28, 2006 - 20:29
Project:Drupal
Version:4.7.x-dev
Component:comment.module
Category:bug report
Priority:minor
Assigned:Zen
Status:closed
Description

I' m using a smiley module. I have entered ':)' as comment body. After all filters are done, ':)' will be replaced with

<?php
<p><img class="smiley" src="/emoticon/smile.gif" width="24" height="24" title="Smiling" alt="Smiling" /></p>
?>

Nice.

And the following code will make us a zero-length code due to strip_tags magic.

<?php
 
if (trim($form_values['subject']) == '') {
   
// The body may be in any format, so we:
    // 1) Filter it into HTML
    // 2) Strip out all HTML tags
    // 3) Convert entities back to plain-text.
  // Note: format is checked by check_markup().
   
$form_values['subject'] = truncate_utf8(decode_entities(strip_tags(check_markup($form_values['comment'], $form_values['format']))), 29, TRUE);
  }
  return
$form_values;
}
?>

Well. I know you can say - its smileys issue. But I think ot only smiley, even some full-working module can break Drupal functionality in such a way.

The solution: the best I think is to ask user to enter a comment title, 'cos it can't be automattically generated.

#1

webchick - April 28, 2006 - 23:39
Priority:critical» minor

Critical?

Sorry, I don't think so.

#2

Zen - May 1, 2006 - 13:39
Category:bug report» feature request

This is a module issue or you can make a feature request to have a "required" option in the comment configuration page for comment subjects (which would be nice).

Marking as a feature request.

Thanks
-K

#3

doq - May 2, 2006 - 09:25
Version:4.7.0-rc4» 4.7.0
Category:feature request» bug report
Priority:minor» normal

try to post <p></p> and you'll see comment with no title. No external modules, just default input format.
I can develop patch if anybody interesting in fixing this.

#4

magico - September 15, 2006 - 15:27
Version:4.7.0» 4.7.3
Status:active» fixed

I posted the following comment

<p>this should create a title</p>
more text more text more text more text

It generates the following title: this should create a

#5

webchick - September 15, 2006 - 15:31
Status:fixed» active

No, not <p>...</p>, but <p></p>.

#6

magico - September 15, 2006 - 16:04

If we post

<p></p>text after
more more moremore more

We get a title text after more more

It's normal that if we only put some empty tags in HTML they will not show up. If we do not want to allow these kind of posts then look here http://drupal.org/node/67348

#7

Zen - October 18, 2006 - 07:23
Priority:normal» minor

@doq: Please submit a patch for this (that validates the subject rather than make the subject mandatory) - thanks :) I'll be happy to review it.

Cheers,
-K

#8

Zen - November 1, 2006 - 15:17
Title:Comment title might be not generated automatically» Comment subject is calculated incorrectly when the comment text contains only HTML tags
Version:4.7.3» 4.7.4
Assigned to:Anonymous» Zen
Status:active» needs review

Patch attached.

-K

AttachmentSize
comment_subject.patch 1.13 KB

#9

Zen - November 1, 2006 - 15:44

Patch attached.

-K

AttachmentSize
comment_subject_0.patch 1.13 KB

#10

killes@www.drop.org - December 11, 2006 - 17:22
Version:4.7.4» 5.x-dev

moving

#11

Steven - December 12, 2006 - 06:07
Status:needs review» patch (to be ported)

Committed a slightly different patch to head, using t('No subject') instead of message_na(), which was removed.

#12

killes@www.drop.org - December 12, 2006 - 20:21
Version:5.x-dev» 4.7.x-dev
Status:patch (to be ported)» fixed

backported

#13

Anonymous - December 26, 2006 - 20:30
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.