[extensions-web] review: Don't use markup in the diff view
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] review: Don't use markup in the diff view
- Date: Tue, 26 Jun 2012 20:23:19 +0000 (UTC)
commit 27a193e66574903480958b8e75f62e00f4b811c9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Jun 26 11:26:58 2012 -0400
review: Don't use markup in the diff view
sweettooth/review/views.py | 12 ++++--------
sweettooth/static/js/diff.js | 4 ++--
2 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/sweettooth/review/views.py b/sweettooth/review/views.py
index d78157c..247195d 100644
--- a/sweettooth/review/views.py
+++ b/sweettooth/review/views.py
@@ -15,7 +15,6 @@ from django.http import HttpResponseForbidden, Http404
from django.shortcuts import redirect, get_object_or_404
from django.template import Context
from django.template.loader import render_to_string
-from django.utils.html import escape
from django.views.decorators.http import require_POST
from review.diffutils import get_chunks
@@ -121,11 +120,8 @@ def get_diff(old_zipfile, new_zipfile, filename):
old.close()
new.close()
- oldmarkup = escape(oldcontent)
- newmarkup = escape(newcontent)
-
- oldlines = oldmarkup.splitlines()
- newlines = newmarkup.splitlines()
+ oldlines = oldcontent.splitlines()
+ newlines = newcontent.splitlines()
chunks = list(get_chunks(oldlines, newlines))
return dict(chunks=chunks,
@@ -206,13 +202,13 @@ def ajax_get_file_diff_view(request, version):
elif filename in old_filelist:
# File was deleted.
f = old_zipfile.open(filename, 'r')
- lines = escape(f.read()).splitlines()
+ lines = f.read().splitlines()
f.close()
return dict(chunks=get_fake_chunks(len(lines), 'delete'), oldlines=lines, newlines=[])
elif filename in new_filelist:
# File was added.
f = new_zipfile.open(filename, 'r')
- lines = escape(f.read()).splitlines()
+ lines = f.read().splitlines()
f.close()
return dict(chunks=get_fake_chunks(len(lines), 'insert'), oldlines=[], newlines=lines)
else:
diff --git a/sweettooth/static/js/diff.js b/sweettooth/static/js/diff.js
index 4f43a38..be1f313 100644
--- a/sweettooth/static/js/diff.js
+++ b/sweettooth/static/js/diff.js
@@ -53,7 +53,7 @@ define(['jquery'], function($) {
var $row = $('<tr>', {'class': 'diff-line equal'}).
append($('<td>', {'class': 'old linum'}).text(oldLinum)).
append($('<td>', {'class': 'new linum'}).text(newLinum)).
- append($('<td>', {'class': 'new contents'}).html(contents));
+ append($('<td>', {'class': 'new contents'}).text(contents));
if (chunk.collapsable) {
if (i == 0) {
@@ -93,7 +93,7 @@ define(['jquery'], function($) {
// half-row.
function buildReplaceRegions(regions, contents) {
function span(tag, text) {
- return $('<span>', {'class': 'diff-inline'}).addClass(tag).html(text);
+ return $('<span>', {'class': 'diff-inline'}).addClass(tag).text(text);
}
function unchanged(text) { return span('unchanged', text); }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]