From b9a96acf2553cda171ad9c9c7ddcb8a30d7700d4 Mon Sep 17 00:00:00 2001 From: Ethan Date: Sat, 26 May 2018 17:20:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MyHttp.php | 4 ++-- src/MyHttpTrait.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MyHttp.php b/src/MyHttp.php index 5a66581..ef4657d 100755 --- a/src/MyHttp.php +++ b/src/MyHttp.php @@ -94,7 +94,7 @@ public function rename($key, $newKey) $res = $client->post($this->api, $this->appendSign(array( 'action' => 'move', 'key' => $key, - 'newKey' => $key, + 'newKey' => $newKey, ))); $this->error = $res->getBody(); @@ -121,7 +121,7 @@ public function copy($key, $newKey) $res = $client->post($this->api, $this->appendSign(array( 'action' => 'copy', 'key' => $key, - 'newKey' => $key, + 'newKey' => $newKey, ))); $this->error = $res->getBody(); diff --git a/src/MyHttpTrait.php b/src/MyHttpTrait.php index ed2ff17..0451110 100644 --- a/src/MyHttpTrait.php +++ b/src/MyHttpTrait.php @@ -107,10 +107,10 @@ private function _doUpload(Request $request) private function checkFilename($filename) { // 必须限定在baseDir目录内,不能出现 .. - // (\w+\/)* 目录可有可无 - // \w+ 文件名必须有 + // ([\w\-]+\/)* 目录可有可无 (字母 数字 下划线 中杠) + // [\w\-]+ 文件名必须有 // (\.\w+)* 扩展名可有可无 - if (!preg_match('/^(\w+\/)*\w+(\.\w+)*$/', $filename)) { + if (!preg_match('/^([\w\-]+\/)*[\w\-]+(\.\w+)*$/', $filename)) { throw new \Exception('filename error'); } }