Download & Extend

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

Project:Drupal core
Version:4.7.x-dev
Component:comment.module
Category:bug report
Priority:minor
Assigned:Zen
Status:closed (fixed)

Issue Summary

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.

Comments

#1

Priority:critical» minor

Critical?

Sorry, I don't think so.

#2

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

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

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

Status:fixed» active

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

#6

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

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

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

AttachmentSizeStatusTest resultOperations
comment_subject.patch1.13 KBIgnored: Check issue status.NoneNone

#9

Patch attached.

-K

AttachmentSizeStatusTest resultOperations
comment_subject_0.patch1.13 KBIgnored: Check issue status.NoneNone

#10

Version:4.7.4» 5.x-dev

moving

#11

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

Version:5.x-dev» 4.7.x-dev
Status:patch (to be ported)» fixed

backported

#13

Status:fixed» closed (fixed)