Changeset 133

Show
Ignore:
Timestamp:
04/15/06 15:24:13 (3 years ago)
Author:
michiel
Message:

Fix order of stripslashes/htmlspecialchars etc.
When inserting in the db the addslashes/preg_quote is done as first action.
When reading the data in php, we should do stripslashes as first too.
This to prevent undefined behaviour.

Re #56

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/common/functions_blog.php

    r132 r133  
    203203                                <span class="log_subject"> 
    204204                                        <?=$row["title"]?> 
    205                                         &nbsp;&nbsp;<span class="log_cat">posted by: <?=stripslashes(htmlspecialchars($row["name"]))?><? if ($row["ip"]) { ?>&nbsp;(<?=obfuscate_ip($row["ip"])?>)<? } ?> on: <?=date("d-m-Y H:i", $row["date"])?></span> 
     205                                        &nbsp;&nbsp;<span class="log_cat">posted by: <?=htmlspecialchars(stripslashes($row["name"]))?><? if ($row["ip"]) { ?>&nbsp;(<?=obfuscate_ip($row["ip"])?>)<? } ?> on: <?=date("d-m-Y H:i", $row["date"])?></span> 
    206206                                </span> 
    207207                        </div> 
     
    212212                                                echo "[Comment deleted by admin on ".date("d-m-Y H:i", $row["deleted"])."]"; 
    213213                                        } else { 
    214                                                 echo nl2br(stripslashes(htmlspecialchars(strip_invalid_xml(run_plugins($row["comment"], "text_output"))))); 
     214                                                echo nl2br(htmlspecialchars(strip_invalid_xml(run_plugins(stripslashes($row["comment"]), "text_output")))); 
    215215                                        } 
    216216                                        ?> 
     
    219219                                        <? if (!$row["deleted"]) { ?> 
    220220                                                <? if ($row["email"]) { ?> 
    221                                                         <br /><span class="log_cat"><a href="mailto:<?=stripslashes(htmlspecialchars($row["email"]))?>"><img src="common/images/icon-email.gif" alt="email" border="0" /><?=stripslashes(htmlspecialchars($row["email"]))?></a></span> 
     221                                                        <br /><span class="log_cat"><a href="mailto:<?=htmlspecialchars(stripslashes($row["email"]))?>"><img src="common/images/icon-email.gif" alt="email" border="0" /><?=htmlspecialchars(stripslashes($row["email"]))?></a></span> 
    222222                                                <? } ?> 
    223223                                                <? if ($row["website"] && $row["website"] != "http://") { ?> 
    224                                                         <span class="log_cat"><a href="<?=stripslashes(htmlspecialchars($row["website"]))?>" title="my website"><img src="common/images/icon-www.gif" alt="my website" border="0" /><?=stripslashes(htmlspecialchars($row["website"]))?></a></span> 
     224                                                        <span class="log_cat"><a href="<?=htmlspecialchars(stripslashes($row["website"]))?>" title="my website"><img src="common/images/icon-www.gif" alt="my website" border="0" /><?=htmlspecialchars(stripslashes($row["website"]))?></a></span> 
    225225                                                <? } ?> 
    226226                                        <? } ?> 
     
    255255                <div class="log_head"> 
    256256                        <table><tr> 
    257                                 <td>name:</td><td><input type="text" name="comment_author" size="30" value="<?=stripslashes(htmlspecialchars($comment_authorinfo["author"]))?>" /></td> 
     257                                <td>name:</td><td><input type="text" name="comment_author" size="30" value="<?=htmlspecialchars(stripslashes($comment_authorinfo["author"]))?>" /></td> 
    258258                        </tr><tr> 
    259                                 <td>email:</td><td><input type="text" name="comment_email" size="30" value="<?=stripslashes(htmlspecialchars($comment_authorinfo["email"]))?>" /></td> 
     259                                <td>email:</td><td><input type="text" name="comment_email" size="30" value="<?=htmlspecialchars(stripslashes($comment_authorinfo["email"]))?>" /></td> 
    260260                        </tr><tr> 
    261                                 <td>url:</td><td><input type="text" name="comment_url" size="30" value="<?=stripslashes(htmlspecialchars($comment_authorinfo["url"]))?>" /></td> 
     261                                <td>url:</td><td><input type="text" name="comment_url" size="30" value="<?=htmlspecialchars(stripslashes($comment_authorinfo["url"]))?>" /></td> 
    262262                        </tr><tr> 
    263263                                <td>title:</td><td><input type="text" name="comment_title" size="30" value="" /></td> 
     
    313313                while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { 
    314314                        if($row["image"]) { 
    315                                 echo "\t<li class=\"link_list_item\"><a href=\"".stripslashes(htmlspecialchars($row["url"]))."\"><img src=\"".stripslashes($row["image"])."\" alt=\"".stripslashes($row["linktitle"])."\" /></a></li>\n"; 
     315                                echo "\t<li class=\"link_list_item\"><a href=\"".htmlspecialchars(stripslashes($row["url"]))."\"><img src=\"".stripslashes($row["image"])."\" alt=\"".stripslashes($row["linktitle"])."\" /></a></li>\n"; 
    316316                        } else { 
    317                                 echo "\t<li class=\"link_list_item\"><a href=\"".stripslashes(htmlspecialchars($row["url"]))."\">".stripslashes($row["linktitle"])."</a></li>\n"; 
     317                                echo "\t<li class=\"link_list_item\"><a href=\"".htmlspecialchars(stripslashes($row["url"]))."\">".stripslashes($row["linktitle"])."</a></li>\n"; 
    318318                        } 
    319319                }