Symfony2.1でスラッグをどのように確保しますか?
悪意のあるユーザーが";rm -rf *"
id値に追加し、Webサイト全体を削除する可能性があります。symfony2.1では、スラッグを固定する簡単な方法はありますか?
私はこの方法でIDを確保しようとしました。
/**
* The idea is to check that the slug cart_id is an id and not
*
* @Route("/{cart_id}/show", name="show_cart")
* @Template()
*/
public function showCartAction($cart_id)
{
if (!preg_match("/^[0-9]{2}$/", $cart_id))
{
throw new \Exception("the id is not correct");
}
$cart = $this->getCartManager()
->getCart($cart_id);
return array(
'cart'=> cart
);
}
これは必要だと思いますか?このようにしますか?