Force encoding and stip filename in Theme::parse_urls

This commit is contained in:
chris2tof 2011-09-01 19:14:34 +08:00
parent 9101a2921e
commit 25355e9c7f
1 changed files with 2 additions and 2 deletions

View File

@ -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]
}