Browse Source

[filebrowser] HTML-escape the contents of the fileviewer

This is useful for viewing XML files, for example.

It's inappropriate to use the Django template's "escape" function with Mako.
That produces an object that Mako doesn't understand.
bc Wong 13 years ago
parent
commit
00cd20c9fc
1 changed files with 3 additions and 3 deletions
  1. 3 3
      apps/filebrowser/src/filebrowser/templates/display.mako

+ 3 - 3
apps/filebrowser/src/filebrowser/templates/display.mako

@@ -16,7 +16,7 @@
 ## limitations under the License.
 ## limitations under the License.
 <%!
 <%!
   import datetime
   import datetime
-  from django.template.defaultfilters import urlencode, escape, stringformat, date, filesizeformat, time
+  from django.template.defaultfilters import urlencode, stringformat, date, filesizeformat, time
   from filebrowser.views import truncate
   from filebrowser.views import truncate
 %>
 %>
 <%
 <%
@@ -132,7 +132,7 @@ ${wrappers.head(truncate(filename)+' :: File Viewer', show_upload=False, show_ne
     % endif
     % endif
       <div>
       <div>
       % if 'contents' in view:
       % if 'contents' in view:
-             <div><pre><code>${view['contents']|escape}</code></pre></div>
+             <div><pre>${view['contents']|h}</pre></div>
       % else:
       % else:
         <table>
         <table>
           % for offset, words, masked in view['xxd']:
           % for offset, words, masked in view['xxd']:
@@ -167,4 +167,4 @@ ${wrappers.head(truncate(filename)+' :: File Viewer', show_upload=False, show_ne
 			});
 			});
 		});
 		});
 	</script>
 	</script>
-${wrappers.foot()}
+${wrappers.foot()}