Code: Select all
$id = $content = 'default';
if(isset($_GET['id'])) {
$id = stripslashes($_GET['id']);
}
if(isset($_GET['content'])) {
$content = stripslashes($_GET['content']);
}
if(!eregi('^[a-z[]]*$',$id) || !eregi('^[a-z[]]*$',$content)) {
$id = $content = 'default';
}Code: Select all
$id = $content = 'default';
if(isset($_GET['id'])) {
$id = stripslashes($_GET['id']);
}
if(isset($_GET['content'])) {
$content = stripslashes($_GET['content']);
}
<p id="<?php echo htmlspecialchars($id,ENT_QUOTES); ?>"><?php echo strip_tags($content); ?></p>While I love PHP and believe it's absolutely awesome, these are some cases where certain architectural designs have resulted in seemingly innocuous bits of code being security risks. I was surprised by all three of these problems when I first heard about them, as well as when I heard about this new one by Esser. I believe it's important that we not write these problems off as "real, but difficult to exploit." Instead, we should file them away, and provide them as compelling reasons why newbies should adopt what we call "best practices".