From 25355e9c7ffc6e59b078c172dcf9e76e1e86eaf1 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 1 Sep 2011 19:14:34 +0800 Subject: [PATCH] Force encoding and stip filename in Theme::parse_urls --- app/models/design/theme.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index c1c2caf6..612f4fbd 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -6,14 +6,14 @@ class Theme < Stylesheet before_save :set_name def parse_urls - orig_content = content = self.file.read + orig_content = content = self.file.read.force_encoding("UTF-8") self.remove_file! self.remove_file_orig! names = [] images = self.design.images content.scan(/(?<=url\()(.*?)(?=\))/){ css_name = $1 - name = File.basename(css_name).gsub(/[\\\"]/, '') + name = File.basename(css_name).gsub(/[\\\"]/, '').strip file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil names << [css_name, file_name] }