mirror of
https://github.com/typecho/typecho.git
synced 2025-01-17 12:38:28 +01:00
为文件上传加入token保护
对文件名做更加严格的过滤
This commit is contained in:
parent
fa7bc750f0
commit
a4f93e0231
@ -120,11 +120,10 @@ $(document).ready(function() {
|
||||
$('#tab-files').bind('init', function () {
|
||||
var uploader = new plupload.Uploader({
|
||||
browse_button : $('.upload-file').get(0),
|
||||
url : '<?php $options->index('/action/upload'
|
||||
url : '<?php $security->index('/action/upload'
|
||||
. (isset($fileParentContent) ? '?cid=' . $fileParentContent->cid : '')); ?>',
|
||||
runtimes : 'html5,flash,silverlight,html4',
|
||||
runtimes : 'html5,flash,html4',
|
||||
flash_swf_url : '<?php $options->adminUrl('js/Moxie.swf'); ?>',
|
||||
silverlight_xap_url : '<?php $options->adminUrl('js/Moxie.xap'); ?>',
|
||||
drop_element : $('.upload-area').get(0),
|
||||
filters : {
|
||||
max_file_size : '<?php echo $phpMaxFilesize ?>',
|
||||
|
Binary file not shown.
@ -144,10 +144,9 @@ $(document).ready(function() {
|
||||
|
||||
var uploader = new plupload.Uploader({
|
||||
browse_button : $('.upload-file').get(0),
|
||||
url : '<?php $options->index('/action/upload?do=modify&cid=' . $attachment->cid); ?>',
|
||||
runtimes : 'html5,flash,silverlight,html4',
|
||||
url : '<?php $security->index('/action/upload?do=modify&cid=' . $attachment->cid); ?>',
|
||||
runtimes : 'html5,flash,html4',
|
||||
flash_swf_url : '<?php $options->adminUrl('js/Moxie.swf'); ?>',
|
||||
silverlight_xap_url : '<?php $options->adminUrl('js/Moxie.xap'); ?>',
|
||||
drop_element : $('.upload-area').get(0),
|
||||
filters : {
|
||||
max_file_size : '<?php echo $phpMaxFilesize ?>',
|
||||
|
@ -37,7 +37,6 @@ class Widget_Login extends Widget_Abstract_Users implements Widget_Interface_Do
|
||||
/** 初始化验证类 */
|
||||
$validator = new Typecho_Validate();
|
||||
$validator->addRule('name', 'required', _t('请输入用户名'));
|
||||
$validator->addRule('name', 'xssCheck', _t('请不要使用特殊字符'));
|
||||
$validator->addRule('password', 'required', _t('请输入密码'));
|
||||
|
||||
/** 截获验证异常 */
|
||||
|
@ -200,7 +200,9 @@ class Widget_Metas_Category_Edit extends Widget_Abstract_Metas implements Widget
|
||||
$name->addRule('required', _t('必须填写分类名称'));
|
||||
$name->addRule(array($this, 'nameExists'), _t('分类名称已经存在'));
|
||||
$name->addRule(array($this, 'nameToSlug'), _t('分类名称无法被转换为缩略名'));
|
||||
$name->addRule('xssCheck', _t('请不要在分类名称中使用特殊字符'));
|
||||
$slug->addRule(array($this, 'slugExists'), _t('缩略名已经存在'));
|
||||
$slug->addRule('xssCheck', _t('请不要在缩略名中使用特殊字符'));
|
||||
}
|
||||
|
||||
if ('update' == $action) {
|
||||
|
@ -182,7 +182,9 @@ class Widget_Metas_Tag_Edit extends Widget_Abstract_Metas implements Widget_Inte
|
||||
$name->addRule('required', _t('必须填写标签名称'));
|
||||
$name->addRule(array($this, 'nameExists'), _t('标签名称已经存在'));
|
||||
$name->addRule(array($this, 'nameToSlug'), _t('标签名称无法被转换为缩略名'));
|
||||
$name->addRule('xssCheck', _t('请不要标签名称中使用特殊字符'));
|
||||
$slug->addRule(array($this, 'slugExists'), _t('缩略名已经存在'));
|
||||
$slug->addRule('xssCheck', _t('请不要在缩略名中使用特殊字符'));
|
||||
}
|
||||
|
||||
if ('update' == $action) {
|
||||
|
@ -65,6 +65,7 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
|
||||
*/
|
||||
private static function getSafeName(&$name)
|
||||
{
|
||||
$name = str_replace(array('"', '<', '>'), '', $name);
|
||||
$name = str_replace('\\', '/', $name);
|
||||
$name = false === strpos($name, '/') ? ('a' . $name) : str_replace('/', '/a', $name);
|
||||
$info = pathinfo($name);
|
||||
@ -414,6 +415,7 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
|
||||
public function action()
|
||||
{
|
||||
if ($this->user->pass('contributor', true) && $this->request->isPost()) {
|
||||
$this->security->protect();
|
||||
if ($this->request->is('do=modify&cid')) {
|
||||
$this->modify();
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user