aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/View
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/View')
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm23
1 files changed, 9 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
index 8f1aaa085..63aade4c9 100644
--- a/perllib/FixMyStreet/App/View/Web.pm
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use mySociety::Locale;
+use mySociety::Web qw(ent);
use FixMyStreet;
use CrossSell;
@@ -17,7 +18,7 @@ __PACKAGE__->config(
render_die => 1,
expose_methods => [
'loc', 'nget', 'tprintf', 'display_crosssell_advert', 'prettify_epoch',
- 'split_into_lines',
+ 'add_links',
],
);
@@ -106,27 +107,21 @@ sub prettify_epoch {
return Page::prettify_epoch( $c->req, $epoch, $short_bool );
}
-=head2 split_into_lines
+=head2 add_links
- [% FOREACH line IN split_into_lines( text ) %]
- <p>
- [% line | html %]
- </p>
- [% END %]
+ [% add_links( text ) | html_para %]
-Split some text into an array of lines on double new lines.
+Add some links to some text (and thus HTML-escapes the other text.
=cut
-sub split_into_lines {
+sub add_links {
my ( $self, $c, $text ) = @_;
- my @lines;
$text =~ s/\r//g;
-
- @lines = split /\n{2,}/, $text;
-
- return \@lines;
+ $text = ent($text);
+ $text =~ s{(https?://[^\s]+)}{<a href="$1">$1</a>}g;
+ return $text;
}
1;