From 23742b8fe2c698d070c852500a345eae01050449 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 2 Dec 2009 22:40:08 -0500 Subject: [PATCH] fix issue with periods in directory names --- classes/ComicPressMediaHandling.inc | 7 ++++++- test/ComicPressMediaHandlingTest.php | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 11ac09b..887c1aa 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -58,6 +58,11 @@ class ComicPressMediaHandling { return $result; } + function _resolve_regex_path($input) { + $input = str_replace('\.', '.', $input); + return $input; + } + // @codeCoverageIgnoreStart function _abspath() { return realpath(ABSPATH); @@ -85,7 +90,7 @@ class ComicPressMediaHandling { } function _read_directory($pattern) { - $dirname = dirname($pattern); + $dirname = $this->_resolve_regex_path(dirname($pattern)); $results = false; if (is_dir($dirname)) { $results = array(); diff --git a/test/ComicPressMediaHandlingTest.php b/test/ComicPressMediaHandlingTest.php index d41b15b..03ab451 100644 --- a/test/ComicPressMediaHandlingTest.php +++ b/test/ComicPressMediaHandlingTest.php @@ -141,6 +141,20 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { $this->assertEquals($expected_results, $this->cpmh->_read_directory($pattern)); } + function providerTestResolveRegexPath() { + return array( + array('test', 'test'), + array('te\.st', 'te.st') + ); + } + + /** + * @dataProvider providerTestResolveRegexPath + */ + function testResolveRegexPath($input, $expected_output) { + $this->assertEquals($expected_output, $this->cpmh->_resolve_regex_path($input)); + } + function providerTestPreHandleComicPathResults() { return array( array('', '', false),