From 90ffaeda77975769974120a61013221b020f1d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Mon, 13 Jan 2014 22:21:01 +0100 Subject: [PATCH] Fix the url in CSS when there's not space. Properly test the component before accessing it Don't handle & if handling src:url --- epubfs.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/epubfs.php b/epubfs.php index 76c71bd..f6f5a92 100644 --- a/epubfs.php +++ b/epubfs.php @@ -21,12 +21,13 @@ $book = new EPub ($myBook->getFilePath ("EPUB", $idData)); $book->initSpineComponent (); -$component = $_GET["comp"]; - -if (empty ($component)) { +if (!isset ($_GET["comp"])) { notFound (); + return; } +$component = $_GET["comp"]; + try { $data = $book->component ($component); $directory = dirname ($component); @@ -48,13 +49,17 @@ try { } $comp = $book->getComponentName ($component, $path); if (!$comp) return "#"; - return str_replace ("&", "&", "{$method}'epubfs.php?{$add}comp={$comp}{$hash}'{$end}"); + $out = "{$method}'epubfs.php?{$add}comp={$comp}{$hash}'{$end}"; + if ($end) { + return $out; + } + return str_replace ("&", "&", $out); }; $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*url\()(.*?)\)/", $callback, $data); $expires = 60*60*24*14; header("Pragma: public");