Subject cannot be longer than 64 characters

CompShack - August 30, 2008 - 21:03
Project:Re: Comment subjects
Version:5.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:ahoeben
Status:closed
Description

minor bug to report! The error about happenes if you are trying to leave a comment for a node that has a title more than 64 characters.

It is a little bit confusing for users leaving comments. I suggested fix is to allow the module to automatically trip any characters that are passed the 64 character limit on the comment subject.

You can test the following bug at the following URL http://www.compshack.com/forum/peoplesoft/peoplesoft-technical/strange-i...

Please let me know what you think?

#1

ahoeben - August 31, 2008 - 15:16

Thanks, I'll look in to this.

#2

ron_s - September 25, 2008 - 01:26

I'm having the same problems on my site. I've had several users tell me they couldn't post comments on particular blog entries. Then I realized the reason why is the blog entries had really long titles, and therefore the default comment subject was longer than 64 characters.

No error message is presented to the user, it just returns to the page to fill out the comment again. Would be better if a really long title is truncated to be something like "Re: A really long title, a really long title, a really long title..."

#3

ahoeben - September 25, 2008 - 09:07

I'm sorry, I have been busy with other things lately. A patch is fairly trivial, but I've had no time for it yet.

#4

arhak - October 8, 2008 - 07:56

is this an issue of this module?
shouldn't be the comment.module which reports a validation error?
besides, this module might take care of not proposing long subject, but I think it should be truncated by comment.module, or at least reported as a validation error so this module would have to check for it first.

#5

ahoeben - October 8, 2008 - 09:09

Yes, it's an issue of this module. The subject title is generated programmatically, and the created value can not always be used as is. The module should be smarter than that.

Attached is a patch, that needs some testing before I create new packages (for 4.7.x, 5.x and 6.x).

AttachmentSize
subject_truncate.patch 884 bytes

#6

ahoeben - October 8, 2008 - 09:09
Assigned to:Anonymous» ahoeben
Status:active» needs review

#7

arhak - October 8, 2008 - 13:06

well, yeah, this module should truncate, but.. doesn't have comment module to complain about validation?
I'm asking if there is also a flaw on comment module?

#8

jaydub - October 21, 2008 - 06:32

Works in testing for me.

#9

jaydub - October 22, 2008 - 06:17

Have to make a small adjustment to account for the ' ...' dots added as
a result of the 4th parameter to the truncate_utf8() call

    // comment subjects can not be longer than 64 characters
    $subject = truncate_utf8($subject, 64, TRUE, TRUE);

should be

    // comment subjects can not be longer than 64 characters
    $subject = truncate_utf8($subject, 60, TRUE, TRUE);

alternatively you can drop the use of the ' ...' dots and set back to 64

#10

ahoeben - October 23, 2008 - 10:10

truncate_utf8 takes care of that automatically:
http://api.drupal.org/api/function/truncate_utf8

#11

jaydub - October 23, 2008 - 11:28

That's not true in the d5 version of truncate_utf8() although is the case in d6+

After applying the patch I got a further bug report from someone who hit 65 chars so I thought it might be the dots. For the sake of discussion the string was this:

Subway stations to be lengthened, transfer channels to be widened, trains to be lenthend to 8 carriages

Adding the prefix 'Re: ' the string is now:

Re: Subway stations to be lengthened, transfer channels to be widened, trains to be lenthend to 8 carriages

When running that string through the truncate_utf8() function I get a resulting string of:

Re: Subway stations to be lengthened, transfer channels to be ...

which happens to be 65 chars and thus still throws an error.

So for d5 versions, you should set the length to 60 to be safe.

#12

ahoeben - October 23, 2008 - 19:02

You are correct, thanks for testing

#13

CompShack - October 23, 2008 - 23:23

Would this be committed to the d6 branch as well?

#14

arhak - October 27, 2008 - 20:26

wold this have something to do with this particular bug?
line 244, unicode.inc

<?php
 
if ($wordsafe) {
   
$string = drupal_substr($string, 0, $len + 1); // leave one more character
?>

#15

arhak - October 27, 2008 - 20:26

wold this have something to do with this particular bug?
line 244, unicode.inc

<?php
 
if ($wordsafe) {
   
$string = drupal_substr($string, 0, $len + 1); // leave one more character
?>

#16

arhak - October 27, 2008 - 20:27

for a better appreciation
unicode.inc

<?php
function truncate_utf8($string, $len, $wordsafe = FALSE, $dots = FALSE) {

  if (
drupal_strlen($string) <= $len) {
    return
$string;
  }

  if (
$dots) {
   
$len -= 4;
  }

  if (
$wordsafe) {
   
$string = drupal_substr($string, 0, $len + 1); // leave one more character
   
...
?>

#17

ahoeben - November 6, 2008 - 09:01
Title:Subject cannot be longer than 64 characters but is currently 89 characters long.» Subject cannot be longer than 64 characters
Status:needs review» fixed

Fixed in 1.4 releases for D4.7 - D6. New release packages should appear within 24 ours.

#18

System Message - November 20, 2008 - 09:02
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.