ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: emanuele on December 11, 2012, 05:48:29 pm

Title: [regression] - AJAX preview doesn't report missing subject and body
Post by: emanuele on December 11, 2012, 05:48:29 pm
Just noticed, but I'm playing with other things... O:)
Title: Re: [bug] - AJAX preview doesn't report missing subject and body
Post by: emanuele on December 11, 2012, 06:50:17 pm
Okay, found it but since I was already playing with Post and Post2 the solution may not be good...
I'll post something tomorrow.

ETA: what I'm trying to do is consolidate some "common" checks in a function and do it both during Post and Post2.
Let me know is it does make sense. ;)
Title: Re: [bug] - AJAX preview doesn't report missing subject and body
Post by: Spuds on December 11, 2012, 07:48:47 pm
I don't think it ever flagged for no subject or body during a preview, those are post2(ing) errors and preview jumps out of post2 purposely before it does those checks (and runs back to post)

Seems like it would be easy to add them in to the really_previewing section, in post, at least the basic checks.  I don't have a strong opinion on this, but does seem a bit unnecessary for preview ... well maybe adding in the subject flag is not bad idea.

ETA: Added in the subject one since it was a one liner
Title: Re: [bug] - AJAX preview doesn't report missing subject and body
Post by: emanuele on December 12, 2012, 03:55:43 am
Quote from: Spuds – I don't think it ever flagged for no subject or body during a preview, those are post2(ing) errors and preview jumps out of post2 purposely before it does those checks (and runs back to post)
It was checking for few things in both the functions:
Code: (function Post) [Select]
		// Validate inputs.
if (empty($context['post_error']))
{
if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['subject'])) == '')
$context['post_error']['no_subject'] = true;
if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['message'])) == '')
$context['post_error']['no_message'] = true;
if (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength'])
$context['post_error']['long_message'] = true;

// Are you... a guest?
if ($user_info['is_guest'])
{
$_REQUEST['guestname'] = !isset($_REQUEST['guestname']) ? '' : trim($_REQUEST['guestname']);
$_REQUEST['email'] = !isset($_REQUEST['email']) ? '' : trim($_REQUEST['email']);

// Validate the name and email.
if (!isset($_REQUEST['guestname']) || trim(strtr($_REQUEST['guestname'], '_', ' ')) == '')
$context['post_error']['no_name'] = true;
elseif ($smcFunc['strlen']($_REQUEST['guestname']) > 25)
$context['post_error']['long_name'] = true;
else
{
require_once($sourcedir . '/Subs-Members.php');
if (isReservedName(htmlspecialchars($_REQUEST['guestname']), 0, true, false))
$context['post_error']['bad_name'] = true;
}

if (empty($modSettings['guest_post_no_email']))
{
if (!isset($_REQUEST['email']) || $_REQUEST['email'] == '')
$context['post_error']['no_email'] = true;
elseif (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_REQUEST['email']) == 0)
$context['post_error']['bad_email'] = true;
}
}

// This is self explanatory - got any questions?
if (isset($_REQUEST['question']) && trim($_REQUEST['question']) == '')
$context['post_error']['no_question'] = true;
Title: Re: [regression] - AJAX preview doesn't report missing subject and body
Post by: Spuds on December 12, 2012, 12:34:04 pm
Ah ... well far be it from me to remove functionality, even if it is dubious :P  I like the idea of consolidating all of that error checking in one place, its pretty messy now and thats even after it got cleaned up some from 2.0.

I must say that really is some ugly code flow just to support non javascirpt users preview  :o
Title: Re: [regression] - AJAX preview doesn't report missing subject and body
Post by: Antechinus on December 12, 2012, 02:53:30 pm
My 2c: non-js users shouldn't expect frills like preview. It's not essential functionality, it's just a luxury that is often not used anyway. If it requires a pile of ugly code that causes problems, I'd drop it.
Title: Re: [regression] - AJAX preview doesn't report missing subject and body
Post by: emanuele on December 12, 2012, 03:31:35 pm
/me feels discriminated... :(

/me forks Dialogo to create a JS-free forum. :P
Title: Re: [regression] - AJAX preview doesn't report missing subject and body
Post by: Antechinus on December 12, 2012, 03:41:10 pm
Quote from: emanuele – /me feels discriminated... :(

/me forks Dialogo to create a JS-free forum. :P
Make a custom theme. :P
Title: Re: [regression] - AJAX preview doesn't report missing subject and body
Post by: TestMonkey on December 12, 2012, 03:43:31 pm
lol... Why you let yerself discriminated?  :o

js ftw...