Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: Rohan_ on July 25, 2011, 12:55:22 PM

Title: Error in post.php
Post by: Rohan_ on July 25, 2011, 12:55:22 PM
Hello,

In my Error Log I see

Undefined index: icon
File: /home/mydomain/public_html/Sources/Post.php
Line: 1615

But postings are fine.. what is causing this ?
Title: Re: Error in post.php
Post by: All Colours Sam on August 03, 2011, 10:25:11 AM
Whats on that line?  can you attach that file here.
Title: Re: Error in post.php
Post by: Rohan_ on August 07, 2011, 09:15:40 AM
I have attached it.. please check
Title: Re: Error in post.php
Post by: MrPhil on August 07, 2011, 09:52:54 AM
Here's the line in question:
'icon' => preg_replace('~[\./\\\\*\':"<>]~', '', $_POST['icon']),
The error message says that there is no "icon" element in the POST data. If that is something reasonable (i.e., not an error condition itself), it could be fixed:
'icon' => preg_replace('~[\./\\\\*\':"<>]~', '', (isset($_POST['icon'])? $_POST['icon'], '')),

Before you do that, the preg_replace search pattern looks a bit odd. It's looking for a single character chosen from:
  \.  -> a literal period  .
/    -> a forward slash  /
\\   -> a backslash  \
\\   -> another backslash  \     ? why ?
*   -> a star  *
\'   -> an apostrophe/single quote  '
:    -> a colon  :
"    -> a quotation mark  "
<   -> a left angle bracket  <
>   -> a right angle bracket  >

I'm wondering if there is an extra backslash in the list, and the intent was to escape (unnecessarily) the * like this: \*
'icon' => preg_replace('~[\./\\\*\':"<>]~', '', $_POST['icon']),

In fact, I think you can remove more of the backslashes:
'icon' => preg_replace('~[./\\*\':"<>]~', '', $_POST['icon']),

I have no idea if this has any bearing on the original problem...