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
Thanks, I'll look in to this.
#2
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
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
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
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).
#6
#7
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
Works in testing for me.
#9
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
truncate_utf8 takes care of that automatically:
http://api.drupal.org/api/function/truncate_utf8
#11
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:
Adding the prefix 'Re: ' the string is now:
When running that string through the truncate_utf8() function I get a resulting string of:
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
You are correct, thanks for testing
#13
Would this be committed to the d6 branch as well?
#14
wold this have something to do with this particular bug?
line 244, unicode.inc<?phpif ($wordsafe) {
$string = drupal_substr($string, 0, $len + 1); // leave one more character
?>
#15
wold this have something to do with this particular bug?
line 244, unicode.inc<?phpif ($wordsafe) {
$string = drupal_substr($string, 0, $len + 1); // leave one more character
?>
#16
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
Fixed in 1.4 releases for D4.7 - D6. New release packages should appear within 24 ours.
#18
Automatically closed -- issue fixed for two weeks with no activity.