aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-01-13 10:57:15 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2015-01-13 20:51:45 +0100
commitc91beccdb04f0437ac6cd8f13c09117ea9766296 (patch)
tree4547fbe8b9eab117f2c3afe34cc6454db9ce155f /views
parent6f3942ce38d0417baf57188eebf9bc2075f2f59a (diff)
downloadgit-arr-fork-c91beccdb04f0437ac6cd8f13c09117ea9766296.zip
blob: cap amount of rendered binary blob content
Although hexdump(1)-style rendering of binary blob content may reveal some meaningful information about the data, it wastes even more storage space than embedding the raw data itself. However, many binary files have a "magic number" or other signature near the beginning of the file, so it is often possible to glean useful information from just the initial chunk of the file without having the entire content available. Thus, limiting the rendered data to just an initial chunk saves storage space while still potentially presenting useful information about the binary content. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
Diffstat (limited to 'views')
-rw-r--r--views/blob.html11
1 files changed, 10 insertions, 1 deletions
diff --git a/views/blob.html b/views/blob.html
index 74c910a..521fe74 100644
--- a/views/blob.html
+++ b/views/blob.html
@@ -48,7 +48,8 @@
binary &mdash; {{'{:,}'.format(len(blob.raw_content))}} bytes
</td>
</tr>
-% for offset, hex1, hex2, text in hexdump(blob.raw_content):
+% lim = 256
+% for offset, hex1, hex2, text in hexdump(blob.raw_content[:lim]):
<tr>
<td class="offset">{{offset}}</td>
<td><pre>{{hex1}}</pre></td>
@@ -56,6 +57,14 @@
<td><pre>{{text}}</pre></td>
</tr>
% end
+% if lim < len(blob.raw_content):
+ <tr class="etc">
+ <td></td>
+ <td>&hellip;</td>
+ <td>&hellip;</td>
+ <td>&hellip;</td>
+ </tr>
+% end
</table>
% elif can_markdown(repo, fname.unicode):
{{!markdown_blob(blob.utf8_content)}}