summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-03-19 15:54:58 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-03-19 15:54:58 +0200
commit4403f71f454d8341fba830db1f0aaf95ef2dc54b (patch)
treec75e18bfd484e5362806cdb6561f16fc3c0c1993 /app
parent2465a4fdb27ff90a58974b2d2dbf191626f53169 (diff)
downloadgitlab-ce-4403f71f454d8341fba830db1f0aaf95ef2dc54b.tar.gz
added sanitize and linkify functions. Moved some js to lib/
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/lib/jquery.timeago.js (renamed from app/assets/javascripts/jquery.timeago.js)0
-rw-r--r--app/assets/javascripts/lib/md5.js (renamed from app/assets/javascripts/md5.js)0
-rw-r--r--app/assets/javascripts/lib/utf8_encode.js (renamed from app/assets/javascripts/utf8_encode.js)0
-rw-r--r--app/assets/javascripts/main.js.coffee8
-rw-r--r--app/assets/javascripts/wall.js.coffee3
5 files changed, 9 insertions, 2 deletions
diff --git a/app/assets/javascripts/jquery.timeago.js b/app/assets/javascripts/lib/jquery.timeago.js
index cc17aa7d3d1..cc17aa7d3d1 100644
--- a/app/assets/javascripts/jquery.timeago.js
+++ b/app/assets/javascripts/lib/jquery.timeago.js
diff --git a/app/assets/javascripts/md5.js b/app/assets/javascripts/lib/md5.js
index b63716eaad2..b63716eaad2 100644
--- a/app/assets/javascripts/md5.js
+++ b/app/assets/javascripts/lib/md5.js
diff --git a/app/assets/javascripts/utf8_encode.js b/app/assets/javascripts/lib/utf8_encode.js
index 39ffe44dae0..39ffe44dae0 100644
--- a/app/assets/javascripts/utf8_encode.js
+++ b/app/assets/javascripts/lib/utf8_encode.js
diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee
index 9fbb1a2d872..b61df846c7a 100644
--- a/app/assets/javascripts/main.js.coffee
+++ b/app/assets/javascripts/main.js.coffee
@@ -32,6 +32,14 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) ->
else
closest_submit.enable()
+window.sanitize = (str) ->
+ return str.replace(/<(?:.|\n)*?>/gm, '')
+
+window.linkify = (str) ->
+ exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig
+ return str.replace(exp,"<a href='$1'>$1</a>")
+
+
$ ->
# Click a .one_click_select field, select the contents
$(".one_click_select").on 'click', -> $(@).select()
diff --git a/app/assets/javascripts/wall.js.coffee b/app/assets/javascripts/wall.js.coffee
index 2b354c32dfa..22a89c35b2c 100644
--- a/app/assets/javascripts/wall.js.coffee
+++ b/app/assets/javascripts/wall.js.coffee
@@ -70,7 +70,7 @@
renderNote: (note) ->
author = '<strong class="wall-author">' + note.author.name + '</strong>'
- body = '<span class="wall-text">' + note.body + '</span>'
+ body = '<span class="wall-text">' + linkify(sanitize(note.body)) + '</span>'
file = ''
time = '<abbr class="timeago" title="' + note.created_at + '">' + note.created_at + '</time>'
@@ -80,4 +80,3 @@
html = '<li>' + author + body + file + time + '</li>'
$('ul.notes').append(html)
-