summaryrefslogtreecommitdiffstats
path: root/template/en/default/attachment
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2010-07-19 00:44:55 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2010-07-19 00:44:55 +0200
commit1ba10751a624a0b94d01aa66c9747fe81cba3e39 (patch)
tree1b24907d69f234b6d0c13034e978a38f5ce3bac3 /template/en/default/attachment
parent2addcaadedfe714bd0502911cc85cdab24736465 (diff)
downloadbugzilla-1ba10751a624a0b94d01aa66c9747fe81cba3e39.tar.gz
bugzilla-1ba10751a624a0b94d01aa66c9747fe81cba3e39.tar.xz
Bug 579749: Linkify the URL found in attachments (restore the is_url behavior) if there is only an URL in them
r/a=LpSolit
Diffstat (limited to 'template/en/default/attachment')
-rw-r--r--template/en/default/attachment/edit.html.tmpl27
1 files changed, 22 insertions, 5 deletions
diff --git a/template/en/default/attachment/edit.html.tmpl b/template/en/default/attachment/edit.html.tmpl
index d1861a7d3..b9e2497fd 100644
--- a/template/en/default/attachment/edit.html.tmpl
+++ b/template/en/default/attachment/edit.html.tmpl
@@ -172,7 +172,7 @@
</b></p>
</div>
[% ELSIF attachment.is_viewable %]
- <div >
+ <div>
[% INCLUDE global/textarea.html.tmpl
id = 'editFrame'
name = 'comment'
@@ -183,10 +183,27 @@
defaultcontent = (attachment.contenttype.match('^text\/')) ?
attachment.data.replace('(.*\n|.+)', '>$1') : undef
%]
- <iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]">
- <b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
- <a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate page</a>.</b>
- </iframe>
+ [%# The regexp is stolen from quoteUrls(), see Template.pm %]
+ [% safe_protocols = constants.SAFE_PROTOCOLS.join('|') %]
+ [% IF attachment.contenttype == 'text/plain'
+ && attachment.data.match("^($safe_protocols):" _ '[^\s<>\"]+[\w\/]$') %]
+ <p>
+ <a href="[% attachment.data FILTER html %]">
+ [% IF attachment.datasize < 120 %]
+ [% attachment.data FILTER html %]
+ [% ELSE %]
+ [% attachment.data FILTER truncate(80) FILTER html %]
+ ...
+ [% attachment.data.match('.*(.{20})$').0 FILTER html %]
+ [% END %]
+ </a>
+ </p>
+ [% ELSE %]
+ <iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]">
+ <b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
+ <a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate page</a>.</b>
+ </iframe>
+ [% END %]
<script type="text/javascript">
<!--
var patchviewerinstalled = 0;