diff --git a/epubfs.php b/epubfs.php index aef2d90..baecf9c 100644 --- a/epubfs.php +++ b/epubfs.php @@ -19,7 +19,7 @@ function getComponentContent ($book, $component, $add) { $method = $m[1]; $path = $m[2]; $end = ""; - if (preg_match ("/^src:/", $method)) { + if (preg_match ("/^src\s*:/", $method)) { $end = ")"; } if (preg_match ("/^#/", $path)) { @@ -42,7 +42,7 @@ function getComponentContent ($book, $component, $add) { $data = preg_replace_callback ("/(src=)[\"']([^:]*?)[\"']/", $callback, $data); $data = preg_replace_callback ("/(href=)[\"']([^:]*?)[\"']/", $callback, $data); $data = preg_replace_callback ("/(\@import\s+)[\"'](.*?)[\"'];/", $callback, $data); - $data = preg_replace_callback ("/(src:\s*url\()(.*?)\)/", $callback, $data); + $data = preg_replace_callback ("/(src\s*:\s*url\()(.*?)\)/", $callback, $data); return $data; } diff --git a/test/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub b/test/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub index 5cfdedc..272af52 100644 Binary files a/test/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub and b/test/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub differ diff --git a/test/EpubFsTest.php b/test/EpubFsTest.php index 4ec44d9..e569771 100644 --- a/test/EpubFsTest.php +++ b/test/EpubFsTest.php @@ -63,4 +63,14 @@ class EpubFsTest extends PHPUnit_Framework_TestCase } $this->assertEquals ('epubfs.php?data=20&comp=css~SLASH~page.css', $import); } + + public function testUrlInCss () { + $data = getComponentContent (self::$book, "css~SLASH~main.css", self::$add); + + $src = ""; + if (preg_match("/url\s*\(\'(.*?)\'\)/", $data, $matches)) { + $src = $matches [1]; + } + $this->assertEquals ('epubfs.php?data=20&comp=fonts~SLASH~times.ttf', $src); + } } \ No newline at end of file