Mercurial > hg > soundsoftware-site
comparison lib/redmine/scm/adapters/abstract_adapter.rb @ 922:ad295b270cd4 live
FIx #446: "non-utf8 paths in repositories blow up repo viewer and reposman" by ensuring the iconv conversion always happens even if source and dest are intended to be the same encoding
author | Chris Cannam |
---|---|
date | Tue, 13 Mar 2012 16:33:49 +0000 |
parents | 851510f1b535 |
children | 18beae6cb226 |
comparison
equal
deleted
inserted
replaced
902:8623d131c9ad | 922:ad295b270cd4 |
---|---|
240 self.class.strip_credential(cmd) | 240 self.class.strip_credential(cmd) |
241 end | 241 end |
242 | 242 |
243 def scm_iconv(to, from, str) | 243 def scm_iconv(to, from, str) |
244 return nil if str.nil? | 244 return nil if str.nil? |
245 return str if to == from | 245 # bug 446: non-utf8 paths in repositories blow up repo viewer and reposman |
246 # -- Remove this short-circuit: we want the conversion to | |
247 # happen always, so we can trap the error here if the | |
248 # source text happens not to be in the advertised | |
249 # encoding (instead of having the database blow up later) | |
250 # return str if to == from | |
246 begin | 251 begin |
247 Iconv.conv(to, from, str) | 252 Iconv.conv(to, from, str) |
248 rescue Iconv::Failure => err | 253 rescue Iconv::Failure => err |
249 logger.error("failed to convert from #{from} to #{to}. #{err}") | 254 logger.error("failed to convert from #{from} to #{to}. #{err}") |
250 nil | 255 nil |