MyBB Community Forums

Full Version: "RE: " included in thread length when previewing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
https://community.mybb.com/thread-116019.html

inc/datahandlers/post.php
	
$subject_length = my_strlen($subject);
if($this->action == "post")
{
	$position_re = my_strpos($subject, "RE: ");
	if($position_re !== false && $position_re == 0)
	{
		$subject_length = $subject_length - 4;
	}
}

if($subject_length > 85)
{
	// Subject is too long
	$this->set_error('subject_too_long', my_strlen($subject));
	return false;
}

Why do we have if($this->action == "post") here? $this->action is null when previewing, throwing errors on users when "RE: " exceeds 85.
It still works, you can post it and code will remove this 4 chars on saving. But big red errors in users face when previewing is no good.

Solution - remove if($this->action == "post"), it should check for "RE: " always when subject is checked.

Also, this error is using $l['subject_too_long'] from contact.lang.php, and it should use $l['postdata_subject_too_long'] from datahandler_post.lang.php. They are the same though, so not a big deal, just noticing.
Heck, on a semi-related note (code quality and stuff):
if($position_re !== false && $position_re == 0)
could be
if($position_re === 0)
since triple-equals will ensure that the types are equal and 0 won't be confused with false.

Just simplifies the conditional a bit, since all that really matters is that my_strpos doesn't return false or some nonzero integer, which, when logically negated, just means having a return value of exactly zero (if I'm not missing some other edge case).
I remember that there was a similar issue quite some time ago which has been fixed (there's even a test thread in the test forum). Need to search that one and check the fix for that.
(2016-11-25, 09:31 AM)JonesĀ H Wrote: [ -> ]I remember that there was a similar issue quite some time ago which has been fixed (there's even a test thread in the test forum). Need to search that one and check the fix for that.

Yup, I think I was the one to report it lol
Which version are you using? I also recall a fix.

And you're definitely wrong about the lang string, contact.lang.php file isn't even loaded in posthandler, set_error() adds a prefix with the datahandler name: https://github.com/mybb/mybb/blob/featur...r.php#L133
(2016-11-25, 08:35 PM)Destroy666 Wrote: [ -> ]Which version are you using? I also recall a fix.
Whoops, not the last one.

(2016-11-25, 08:35 PM)Destroy666 Wrote: [ -> ]And you're definitely wrong about the lang string, contact.lang.php file isn't even loaded in posthandler, set_error() adds a prefix with the datahandler name: https://github.com/mybb/mybb/blob/featur...r.php#L133
Got it
Rejecting then, only bugs for the latest version should be reported.