Undefined $_POST['icon'] in Sources/Post.php

Started by nend, October 16, 2015, 09:17:16 PM

Previous topic - Next topic

nend

When a template doesn't include a value for the post icon a undefined error pops up in the error log. Since the template system is different from the mod system in order to not use the post icon value, a template would either have to send a hidden response or edit Post.php.

Since all post information should be verified if it is actually being sent I would say this is a very minor bug.

Code
// Creating a new topic?
$newTopic = empty($_REQUEST['msg']) && empty($topic);

$_POST['icon'] = !empty($attachIDs) && $_POST['icon'] == 'xx' ? 'clip' : $_POST['icon'];


Simple Fix
// Creating a new topic?
$newTopic = empty($_REQUEST['msg']) && empty($topic);

$_POST['icon'] = empty($_POST['icon']) ? 'xx' : $_POST['icon'];
$_POST['icon'] = !empty($attachIDs) && $_POST['icon'] == 'xx' ? 'clip' : $_POST['icon'];

Kindred

Why is that necessary?  Unless someone breaks the system, posts should never be missing the icon.  If a post is created, it should be created with the default icon...  In what case would it not be?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

nend

If the post template is edited to not include the message icon field. It is trivial, though I figured it was something that should be done since there are already checks in post.php to check the title and message field which is expected to be there. There is no check for the message icon.

Kindred

so...  in other words...

if someone purposefully breaks the design....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

What Kindred means is (methinks) that SMF was designed with the message icon in place. That's why it expects the icon to be defined and, as such, I agree that this isn't really a bug.

If the template doesn't want to include the icon selection, then just add a hidden "icon" field to the form post and set its value to "xx". All is good for everyone ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

live627

Quote from: Kindred on October 17, 2015, 09:25:46 AM
so...  in other words...

if someone purposefully breaks the design....
Really, Kindred, really? This is just so cringe-worthy.

nend

#6
Quote from: Kindred on October 17, 2015, 09:25:46 AM
so...  in other words...

if someone purposefully breaks the design....

I guess or accidentally.  :-\

IMHO all post data should be checked, even if they are always expected to be there, when the data is being passed from a external source.

nend

#7
Lol it worked, Don't know how far I can go, looks like there is a check in there that would prevent me from going beyond that folder but should there be more checks.

I can also make the message icon undefined, which is not by editing the template or source files on this site.

nend

#8
undefined  ;)

nend

So what is the status on this report? Anybody going to fix those 404 not found post icons in the replies above?

Not a bug, huh?

Suki

Added a commit for this, will be available when the main PR gets merged. Thank you for your report.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: