Skip to main content
[regression] - AJAX preview doesn't report missing subject and body Started by emanuele · · Read 11702 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

[regression] - AJAX preview doesn't report missing subject and body

Just noticed, but I'm playing with other things... O:)
Last Edit: December 12, 2012, 05:47:35 am by emanuele
Bugs creator.
Features destroyer.
Template killer.

Re: [bug] - AJAX preview doesn't report missing subject and body

Reply #1

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. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: [bug] - AJAX preview doesn't report missing subject and body

Reply #2

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
Last Edit: December 11, 2012, 07:58:25 pm by Spuds

Re: [bug] - AJAX preview doesn't report missing subject and body

Reply #3

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;
Bugs creator.
Features destroyer.
Template killer.

Re: [regression] - AJAX preview doesn't report missing subject and body

Reply #4

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

Re: [regression] - AJAX preview doesn't report missing subject and body

Reply #5

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.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: [regression] - AJAX preview doesn't report missing subject and body

Reply #6

 emanuele feels discriminated... :(

 emanuele forks Dialogo to create a JS-free forum. :P
Bugs creator.
Features destroyer.
Template killer.

Re: [regression] - AJAX preview doesn't report missing subject and body

Reply #7

Quote from: emanuele –
 emanuele feels discriminated... :(

 emanuele forks Dialogo to create a JS-free forum. :P
Make a custom theme. :P
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: [regression] - AJAX preview doesn't report missing subject and body

Reply #8

lol... Why you let yerself discriminated?  :o

js ftw...
The best moment for testing your PR is right after you merge it. Can't miss with that one.