# HG changeset patch # User Marcin Kuzminski # Date 2011-02-27 02:43:44 # Node ID e7d7f05217c1af14dfdb4e4359cda71f6c3215cf # Parent bc3dafd0e24c54e9a605b1d7bf21af6010c07ec3 replaced all decode('utf-8') instances with .decode('utf-8','replace') for more error prof setup, this way rhodecode could handle displaying non utf8 encoded file paths. This is still an invalid path, but this way we could at least show those paths without errors diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -186,7 +186,7 @@ class _FilesBreadCrumbs(object): def __call__(self, repo_name, rev, paths): if isinstance(paths, str): - paths = paths.decode('utf-8') + paths = paths.decode('utf-8', 'replace') url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, revision=rev, f_path=''))] @@ -683,6 +683,6 @@ def changed_tooltip(nodes): suf = '' if len(nodes) > 30: suf = '
' + _(' and %s more') % (len(nodes) - 30) - return literal(pref + '
'.join([x.path.decode('utf-8') for x in nodes[:30]]) + suf) + return literal(pref + '
'.join([x.path.decode('utf-8', 'replace') for x in nodes[:30]]) + suf) else: return ': ' + _('No Files') diff --git a/rhodecode/templates/changeset/changeset.html b/rhodecode/templates/changeset/changeset.html --- a/rhodecode/templates/changeset/changeset.html +++ b/rhodecode/templates/changeset/changeset.html @@ -81,7 +81,7 @@ ${_('Files affected')}
%for change,filenode,diff,cs1,cs2 in c.changes: -
${h.link_to(filenode.path.decode('utf-8'),h.url.current(anchor=h.repo_name_slug('C%s' % filenode.path.decode('utf-8'))))}
+
${h.link_to(filenode.path.decode('utf-8','replace'),h.url.current(anchor=h.repo_name_slug('C%s' % filenode.path.decode('utf-8','replace'))))}
%endfor
@@ -92,19 +92,19 @@ %if change !='removed':
-
+
- ${h.link_to_if(change!='removed',filenode.path.decode('utf-8'),h.url('files_home',repo_name=c.repo_name, - revision=filenode.changeset.raw_id,f_path=filenode.path.decode('utf-8')))} + ${h.link_to_if(change!='removed',filenode.path.decode('utf-8','replace'),h.url('files_home',repo_name=c.repo_name, + revision=filenode.changeset.raw_id,f_path=filenode.path.decode('utf-8','replace')))} %if 1: » ${h.link_to(_('diff'), - h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='diff'))} + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8','replace'),diff2=cs2,diff1=cs1,diff='diff'))} » ${h.link_to(_('raw diff'), - h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='raw'))} + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8','replace'),diff2=cs2,diff1=cs1,diff='raw'))} » ${h.link_to(_('download diff'), - h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='download'))} + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8','replace'),diff2=cs2,diff1=cs1,diff='download'))} %endif
diff --git a/rhodecode/templates/changeset/changeset_range.html b/rhodecode/templates/changeset/changeset_range.html --- a/rhodecode/templates/changeset/changeset_range.html +++ b/rhodecode/templates/changeset/changeset_range.html @@ -54,7 +54,7 @@ %for cs in c.cs_ranges:
r${cs}
%for change,filenode,diff,cs1,cs2 in c.changes[cs.raw_id]: -
${h.link_to(filenode.path.decode('utf-8'),h.url.current(anchor=h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path.decode('utf-8')))))}
+
${h.link_to(filenode.path.decode('utf-8','replace'),h.url.current(anchor=h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path.decode('utf-8','replace')))))}
%endfor %endfor
@@ -66,19 +66,19 @@ %if change !='removed':
-
+
- ${h.link_to_if(change!='removed',filenode.path.decode('utf-8'),h.url('files_home',repo_name=c.repo_name, - revision=filenode.changeset.raw_id,f_path=filenode.path.decode('utf-8')))} + ${h.link_to_if(change!='removed',filenode.path.decode('utf-8','replace'),h.url('files_home',repo_name=c.repo_name, + revision=filenode.changeset.raw_id,f_path=filenode.path.decode('utf-8','replace')))} %if 1: » ${h.link_to(_('diff'), - h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='diff'))} + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8','replace'),diff2=cs2,diff1=cs1,diff='diff'))} » ${h.link_to(_('raw diff'), - h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='raw'))} + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8','replace'),diff2=cs2,diff1=cs1,diff='raw'))} » ${h.link_to(_('download diff'), - h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='download'))} + h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8','replace'),diff2=cs2,diff1=cs1,diff='download'))} %endif
diff --git a/rhodecode/templates/files/files_browser.html b/rhodecode/templates/files/files_browser.html --- a/rhodecode/templates/files/files_browser.html +++ b/rhodecode/templates/files/files_browser.html @@ -66,7 +66,7 @@ %for cnt,node in enumerate(c.files_list): - ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=node.path),class_=file_class(node))} + ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=node.path.decode('utf-8','replace')),class_=file_class(node))} %if node.is_file():