From 94cac215a74cb9892694fcedf73b1e08c85deffd Mon Sep 17 00:00:00 2001 From: Keith Fahlgren Date: Wed, 9 Jul 2008 19:20:54 +0000 Subject: [PATCH] Fixing CSS mimetype bug reported by Liza Daly --- xsl/epub/bin/spec/epub_regressions_spec.rb | 23 ++++++++++++++++++++++ xsl/epub/docbook.xsl | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/xsl/epub/bin/spec/epub_regressions_spec.rb b/xsl/epub/bin/spec/epub_regressions_spec.rb index 262516d4d..37a6f1f73 100755 --- a/xsl/epub/bin/spec/epub_regressions_spec.rb +++ b/xsl/epub/bin/spec/epub_regressions_spec.rb @@ -62,6 +62,29 @@ describe DocBook::Epub do end end + it "should use the correct mimetype for CSS files" do + begin + css_file_base = "test.css" + css_file = File.join(@filedir, css_file_base) + css_epub = DocBook::Epub.new(File.join(@testdocsdir, "book.002.xml"), @tmpdir, css_file) + css_epubfile = File.join(@tmpdir, "css.epub") + css_epub.render_to_file(css_epubfile, $DEBUG) + + tmpdir = File.join(Dir::tmpdir(), "epubcssreg"); Dir.mkdir(tmpdir) rescue Errno::EEXIST + + success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{css_epubfile}") + raise "Could not unzip #{css_epubfile}" unless success + opf_files = Dir.glob(File.join(tmpdir, "**", "*.opf")) + opf_files.find_all {|opf_file| + File.open(opf_file).readlines.to_s.should_not =~ /media-type=.test\/css/ + } + rescue => e + raise e + ensure + FileUtils.rm_r(tmpdir, :force => true) + end + end + after(:all) do FileUtils.rm_r(@tmpdir, :force => true) end diff --git a/xsl/epub/docbook.xsl b/xsl/epub/docbook.xsl index b2d324967..feb41f261 100644 --- a/xsl/epub/docbook.xsl +++ b/xsl/epub/docbook.xsl @@ -685,7 +685,7 @@ http://www.idpf.org/2007/opf - test/css + text/css css -- 2.40.0