Created
February 14, 2014 10:48
-
-
Save zenith6/8999156 to your computer and use it in GitHub Desktop.
EC-CUBEの SC_CheckError::FILE_NAME_CHECK_BY_NOUPLOAD() を修正するパッチです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: data/class/SC_CheckError.php | |
=================================================================== | |
--- data/class/SC_CheckError.php (リビジョン 23348) | |
+++ data/class/SC_CheckError.php (作業コピー) | |
@@ -851,7 +851,7 @@ | |
return; | |
} | |
$this->createParam($value); | |
- if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^[[:alnum:]_\.-]+$/i", $this->arrParam[$value[1]]) || preg_match('/[\\]/' ,$this->arrParam[$value[1]])) { | |
+ if (strlen($this->arrParam[$value[1]]) > 0 && preg_match("/[^[:alnum:]_.\\-]/", $this->arrParam[$value[1]])) { | |
$this->arrErr[$value[1]] = '※ ' . $value[0] . 'のファイル名に日本語やスペースは使用しないで下さい。<br />'; | |
} | |
} | |
Index: tests/class/SC_CheckError/SC_CheckError_FILE_NAME_CHECK_BY_NOUPLOADTest.php | |
=================================================================== | |
--- tests/class/SC_CheckError/SC_CheckError_FILE_NAME_CHECK_BY_NOUPLOADTest.php (リビジョン 23348) | |
+++ tests/class/SC_CheckError/SC_CheckError_FILE_NAME_CHECK_BY_NOUPLOADTest.php (作業コピー) | |
@@ -26,10 +26,29 @@ | |
class SC_CheckError_FILE_NAME_CHECK_BY_NOUPLOADTest extends Common_TestCase | |
{ | |
+ public function validValueProvider() | |
+ { | |
+ return array( | |
+ array('a'), | |
+ array('012'), | |
+ array('abc012'), | |
+ array('a.txt'), | |
+ array('a-b.zip'), | |
+ array('a-b_c.tar.gz'), | |
+ ); | |
+ } | |
- /** | |
- * @expectedException PHPUnit_Framework_Error_Warning | |
- */ | |
+ public function invalidValueProvider() | |
+ { | |
+ return array( | |
+ array("line1\nline2"), | |
+ array("a\x00b"), | |
+ array('a/b'), | |
+ array('a b'), | |
+ array('日本語'), | |
+ ); | |
+ } | |
+ | |
public function testFILE_NAME_CHECK_BY_NOUPLOAD_空文字列の場合_エラーをセットしない() | |
{ | |
$arrForm = array('file' => ''); | |
@@ -42,11 +61,11 @@ | |
} | |
/** | |
- * @expectedException PHPUnit_Framework_Error_Warning | |
- */ | |
- public function testFILE_NAME_CHECK_BY_NOUPLOAD_使用できない文字が含まれていない場合_エラーをセットしない() | |
+ * @dataProvider validValueProvider | |
+ */ | |
+ public function testFILE_NAME_CHECK_BY_NOUPLOAD_使用できない文字が含まれていない場合_エラーをセットしない($value) | |
{ | |
- $arrForm = array('file' => 'a_b-c.Z'); | |
+ $arrForm = array('file' => $value); | |
$objErr = new SC_CheckError_Ex($arrForm); | |
$objErr->doFunc(array('label', 'file') ,array('FILE_NAME_CHECK_BY_NOUPLOAD')); | |
@@ -56,21 +75,20 @@ | |
} | |
/** | |
- * @expectedException PHPUnit_Framework_Error_Warning | |
- */ | |
- public function testFILE_NAME_CHECK_BY_NOUPLOAD_使用できない文字が含まれている場合_エラーをセットする() | |
+ * @dataProvider invalidValueProvider | |
+ */ | |
+ public function testFILE_NAME_CHECK_BY_NOUPLOAD_使用できない文字が含まれている場合_エラーをセットする($value) | |
{ | |
- $arrForm = array('file' => 'a/b'); | |
+ $arrForm = array('file' => $value); | |
$objErr = new SC_CheckError_Ex($arrForm); | |
$objErr->doFunc(array('label', 'file') ,array('FILE_NAME_CHECK_BY_NOUPLOAD')); | |
- $this->expected = '※ labelのファイル名に日本語やスペースは使用しないで下さい。<br />'; | |
- $this->actual = $objErr->arrErr['file']; | |
+ $this->expected = true; | |
+ $this->actual = isset($objErr->arrErr['file']); | |
$this->verify(); | |
} | |
/** | |
- * @expectedException PHPUnit_Framework_Error_Warning | |
* @depends testFILE_NAME_CHECK_BY_NOUPLOAD_使用できない文字が含まれている場合_エラーをセットする | |
*/ | |
public function testFILE_NAME_CHECK_BY_NOUPLOAD_他のエラーが既にセットされている場合_エラーを上書きしない() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment