changeset 5590:7425088bc4ff stable

gist: fix unicode file path handling
author Takumi IINO <trot.thunder@gmail.com>
date Mon, 23 Nov 2015 19:01:22 +0900
parents 737c3704b44a
children f3f06692cb7e
files kallithea/controllers/admin/gists.py kallithea/templates/admin/gists/edit.html kallithea/templates/admin/gists/show.html
diffstat 3 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/gists.py	Sat Nov 07 13:16:58 2015 +0100
+++ b/kallithea/controllers/admin/gists.py	Mon Nov 23 19:01:22 2015 +0900
@@ -42,7 +42,7 @@
 from kallithea.lib.base import BaseController, render
 from kallithea.lib.auth import LoginRequired, NotAnonymous
 from kallithea.lib.utils import jsonify
-from kallithea.lib.utils2 import safe_int, time_to_datetime
+from kallithea.lib.utils2 import safe_int, safe_unicode, time_to_datetime
 from kallithea.lib.helpers import Page
 from webob.exc import HTTPNotFound, HTTPForbidden
 from sqlalchemy.sql.expression import or_
@@ -206,7 +206,7 @@
             log.error(traceback.format_exc())
             raise HTTPNotFound()
         if format == 'raw':
-            content = '\n\n'.join([f.content for f in c.files if (f_path is None or f.path == f_path)])
+            content = '\n\n'.join([f.content for f in c.files if (f_path is None or safe_unicode(f.path) == f_path)])
             response.content_type = 'text/plain'
             return content
         return render('admin/gists/show.html')
--- a/kallithea/templates/admin/gists/edit.html	Sat Nov 07 13:16:58 2015 +0100
+++ b/kallithea/templates/admin/gists/edit.html	Mon Nov 23 19:01:22 2015 +0900
@@ -69,8 +69,8 @@
             % for cnt, file in enumerate(c.files):
                 <div id="body" class="codeblock" style="margin-bottom: 4px">
                     <div style="padding: 10px 10px 10px 26px;color:#666666">
-                        <input type="hidden" value="${file.path}" name="org_files">
-                        <input id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${file.path}">
+                        <input type="hidden" value="${h.safe_unicode(file.path)}" name="org_files">
+                        <input id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${h.safe_unicode(file.path)}">
                         <select id="mimetype_${h.FID('f',file.path)}" name="mimetypes"/>
                     </div>
                     <div class="editor_container">
--- a/kallithea/templates/admin/gists/show.html	Sat Nov 07 13:16:58 2015 +0100
+++ b/kallithea/templates/admin/gists/show.html	Mon Nov 23 19:01:22 2015 +0900
@@ -81,9 +81,9 @@
                <div style="border: 1px solid #EEE;margin-top:20px">
                 <div id="${h.FID('G', file.path)}" class="stats" style="border-bottom: 1px solid #DDD;padding: 8px 14px;">
                     <a href="${c.gist.gist_url()}">ΒΆ</a>
-                    <b style="margin:0px 0px 0px 4px">${file.path}</b>
+                    <b style="margin:0px 0px 0px 4px">${h.safe_unicode(file.path)}</b>
                     <div style="float:right; margin: -5px">
-                       ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=file.path),class_="btn btn-mini")}
+                       ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=h.safe_unicode(file.path)),class_="btn btn-mini")}
                     </div>
                 </div>
                 <div class="code-body">