我有一个简单的Ajax Jquery函数,用于发布已编辑的文章数据,然后将其路由到控制器
//Controller articleManagement
function editArticle(){
$a=$this->inputs;
$response=DB::table('articles')
->where('id', $a["id"])
->update(array($a["column"] => $a["val"]));
return $response;
}
//routes.php
Route::post('/xarticle', "articleManagement@editArticle");
//ajax Jquery
$.ajax({
type: "POST",
url: "/xarticle",
data: {
id:id,
val:eval("CKEDITOR.instances.content"+id+".getData()"),
column:"content"
},
success:function(data){
data=Number(data);
Boolean(data)?alertify.success("Data successfully updated."):alertify.error("Nothing was updated.");
}
});
当我在localhost中使用各种val
时,上面的代码工作正常。但是在远程服务器上的生产中它以小值运行,例如“Hello World”“bla bla bla bla bla”但是当我想发布文章并返回404未找到页面错误时它会失败。
此错误显示在laravel.log
中[2014-12-26 23:20:07] production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'
Stack trace:
#0 /home/yahyouha/html/bootstrap/compiled.php(3238): Illuminate\Foundation\Application->abort(404)
#1 /home/yahyouha/html/app/routes.php(53): Illuminate\Support\Facades\Facade::__callStatic('abort', Array)
#2 /home/yahyouha/html/app/routes.php(53): Illuminate\Support\Facades\App::abort(404)
#3 [internal function]: {closure}('xarticle')
#4 /home/yahyouha/html/bootstrap/compiled.php(5331): call_user_func_array(Object(Closure), Array)
#5 /home/yahyouha/html/bootstrap/compiled.php(4998): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#6 /home/yahyouha/html/bootstrap/compiled.php(4986): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#7 /home/yahyouha/html/bootstrap/compiled.php(715): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#8 /home/yahyouha/html/bootstrap/compiled.php(696): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#9 /home/yahyouha/html/bootstrap/compiled.php(7746): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#10 /home/yahyouha/html/bootstrap/compiled.php(8353): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#11 /home/yahyouha/html/bootstrap/compiled.php(8300): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#12 /home/yahyouha/html/bootstrap/compiled.php(10962): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#13 /home/yahyouha/html/bootstrap/compiled.php(657): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#14 /home/yahyouha/public_html/index.php(49): Illuminate\Foundation\Application->run()
#15 {main} [] []
修改
我注意到如果我删除图像代码和其他一些字符它开始工作它可能是从apache的一些配置到不接受特殊字符发布以防止注入?
答案 0 :(得分:0)
我认为你是正确的,服务器正在过滤包含HTML的POST机身,可能使用mod_security rules。您可以通过使用
编码html片段来解决这个问题val: encodeURIComponent(htmlFragment)
在php中你必须解码它(但也许php会自动为你做这个)
urldecode($a["val"])
http://php.net/manual/en/function.urldecode.php http://www.w3schools.com/jsref/jsref_encodeuricomponent.asp