View Full Version : no bug, but a serious problem: empty lines in comments...
-okapi-
04-22-2006, 08:23 AM
it's nice that you can now structure comments by using empty lines, BUT... unfortunately there is no limitation for that feature:
so, a commenter can ruin the layout in seconds by adding 1000 empty lines.
PLEASE, as regards the upcoming 1.5 final, PLEASE add a limitation, both for empty lines and characters, to the comments system!
i think, the current state means a serious problem, as the new anti-spam features are useless in this case. so, basic limitations like those should be considered very soon!
Connie
04-22-2006, 08:46 AM
thanks, that is a good suggestion!
Message field is limited by MySQL Text field size.
Adding new line limitation is a good idea which should be added to final version.
-okapi-
04-22-2006, 09:39 AM
Message field is limited by MySQL Text field size.
how can this be customized?
where in the database?
Joe[y]
04-22-2006, 09:43 AM
how can this be customized?
where in the database?
the actual modification would need to be in the pixelpost base code not in the database. currently there is just a maximum amount of characters per comment (250 i think) which is set in the database.
Nope Joey.
Currently size of message in comment is set up to 65,535 chars (size of TEXT type field). It can be decreased to 255 by setting type of this (message) field to TINY TEXT.
But remember one thing - all special chars needs more then one char in DB. So i.e. polish special char like ę would need 2 chars to be stored as UTF-8 encoded char.
Connie
04-22-2006, 11:56 AM
unfortunately it is not possible to limit the text in a textarea by HTML itself
I never understood why they did not implement...
I think there could be a regex to count the linebreaks
so more than 2 linebreaks in a row should be compressed to 2 linebreaks (maximum)
unfortunately again I do not know how to write these regexes...
Connie it is possible to limit textarea by JS code.
And it is easy to limit line break.
After Ill make small house clean up Ill sit on this issue and give back some hacks.
-okapi-
04-22-2006, 12:23 PM
Connie it is possible to limit textarea by JS code.
And it is easy to limit line break.
After Ill make small house clean up Ill sit on this issue and give back some hacks.
i think this should be done by php code.
i mean both, limitation of empty lines as well as limitation of characters.
hm... it's quite a common feature, i think it can't be so hard to do if one is familiar with pixelpost and php.
If you limit this field only at server side you can get comments like:
"....very interest"
That is why it should be done also at client side.
-okapi-
04-22-2006, 01:49 PM
you're right, GeoS, i understand.
but what we are talking about here, is primarily spam or other destructive actions. for me, any comment that takes more than 300 characters can be regarded as offending, just like spam. i wouldn't worry about a cut like "...very intererest" in that case.
i think, there should be a character limitation primarily to prevent the layout to get ruined.
a line that says: "300 characters allowed" or so would be enough information for the commenter, i think.
For stipping out addtional to more then 2 new lines you should go to line 938 (with line wrap function off in text editor) and find:
// $message
$message = isset($_POST['message']) ? $_POST['message'] : "";
$message = clean_comment($message);
$message = nl2br($message);
and replace it with:
// $message
$message = isset($_POST['message']) ? $_POST['message'] : "";
$message = clean_comment($message);
$message = preg_replace("/((\x0D\x0A){3,}|[\x0A]{3,}|[\x0D]{3,})/","\n\n",$message);
$message = nl2br($message);
Now Im going to find solution for limiting message.
PS CVS updated.
Here you have very easy and short part of code to implement into your image_template.html file:
http://www.dynamicdrive.com/dynamicindex16/maxlength.htm
-okapi-
04-22-2006, 03:05 PM
Here you have very easy and short part of code to implement into your image_template.html file:
http://www.dynamicdrive.com/dynamicindex16/maxlength.htm
thank you, GeoS, that's nice, but as soon as you turn off javascript in your browser, it doesn't work any more, and you can write as many characters as you like. a serverside php-based limitation is also needed.
-okapi-
04-22-2006, 03:21 PM
For stipping out addtional to more then 2 new lines you should go to line 938 (with line wrap function off in text editor) and find:
// $message
$message = isset($_POST['message']) ? $_POST['message'] : "";
$message = clean_comment($message);
$message = nl2br($message);
and replace it with:
// $message
$message = isset($_POST['message']) ? $_POST['message'] : "";
$message = clean_comment($message);
$message = preg_replace("/((\x0D\x0A){3,}|[\x0A]{3,}|[\x0D]{3,})/","\n\n",$message);
$message = nl2br($message);
Now Im going to find solution for limiting message.
PS CVS updated.
thank you, that works nicely, it limits the number of empty lines to 3 (why not only one?).
but there is one more point left: the layout can still be stretched by typing one character in each line, and adding three empty lines, and repeating that until the number of allowed characters has been reached....
so, there should be also a total number of allowed lines!
Exactly it allows only 2 new line because it give option to make new paragraph like:
bla bla bla
bla bla bla 2
And solution for limiting is like that:
replace previous new code:
// $message
$message = isset($_POST['message']) ? $_POST['message'] : "";
$message = clean_comment($message);
$message = preg_replace("/((\x0D\x0A){3,}|[\x0A]{3,}|[\x0D]{3,})/","\n\n",$message);
$message = nl2br($message);
with:
// $message
$message = isset($_POST['message']) ? $_POST['message'] : "";
$message = substr($message, 0, 300); // if you want max 300 chars of comment (remember that special chars uses at least 2 chars instead of "standard" visible 1 char)
$message = clean_comment($message);
$message = preg_replace("/((\x0D\x0A){3,}|[\x0A]{3,}|[\x0D]{3,})/","\n\n",$message);
$message = nl2br($message);
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.