diff --git a/app/controllers/admin/patchfiles_controller.rb b/app/controllers/admin/patchfiles_controller.rb index 9e278c6..382c64e 100644 --- a/app/controllers/admin/patchfiles_controller.rb +++ b/app/controllers/admin/patchfiles_controller.rb @@ -78,6 +78,7 @@ class Admin::PatchfilesController < OrbitAdminController redirect_to admin_patchfiles_showckeditor_path end def newfont + params["patchfilefield"]["new_add_font"] = params["patchfilefield"]["new_add_font"].gsub('\"','').gsub("\'",'').gsub(";",'') @field.new_add_font = params["patchfilefield"]["new_add_font"] rescue (redirect_to admin_patchfiles_showckeditor_path and return) params["patchfilefield"]["font_array"].each_with_index do |(font,istrue),index| if istrue =="0" diff --git a/app/models/patchfilefield.rb b/app/models/patchfilefield.rb index 349af4c..b2449ea 100644 --- a/app/models/patchfilefield.rb +++ b/app/models/patchfilefield.rb @@ -223,20 +223,22 @@ class Patchfilefield end end @delete_font_array.each do |font_to_delete| - @str_above_end = @filedata.index(font_to_delete) - 1 - @str_above_start - for @str_above_start in (0..@str_above_end).to_a.reverse - if @filedata[@str_above_start] =="\'" || @filedata[@str_above_start] =="\"" - break + if @filedata.index(font_to_delete) != nil + @str_above_end = @filedata.index(font_to_delete) - 1 + @str_above_start + for @str_above_start in (0..@str_above_end).to_a.reverse + if @filedata[@str_above_start] =="\'" || @filedata[@str_above_start] =="\"" + break + end + break if @filedata[@str_above_start] == "\;" + end + @str_to_delete = (( @filedata[@str_above_start..@str_above_end].include? "\;") ? @filedata[@str_above_start..@str_above_end] : "")+font_to_delete + @filedata =@filedata.sub(@str_to_delete,"") + for @i in @str_start+1...@str_end + next if @filedata[@i] == " " + break if @filedata[@i] != "\;" + @filedata.slice!(@i) end - break if @filedata[@str_above_start] == "\;" - end - @str_to_delete = (( @filedata[@str_above_start..@str_above_end].include? "\;") ? @filedata[@str_above_start..@str_above_end] : "")+font_to_delete - @filedata =@filedata.sub(@str_to_delete,"") - for @i in @str_start+1...@str_end - next if @filedata[@i] == " " - break if @filedata[@i] != "\;" - @filedata.slice!(@i) end end puts self.used_font