diff --git a/public/templates/albums/show.html b/public/templates/albums/show.html index 3dae5acd..99ecb5d7 100644 --- a/public/templates/albums/show.html +++ b/public/templates/albums/show.html @@ -52,7 +52,7 @@

Description

-

+

Tracks

diff --git a/public/templates/artists/profile.html b/public/templates/artists/profile.html index 6f585836..1c1663f5 100644 --- a/public/templates/artists/profile.html +++ b/public/templates/artists/profile.html @@ -3,7 +3,7 @@

Bio

-

+

diff --git a/public/templates/directives/comments.html b/public/templates/directives/comments.html index eed2b1dd..35c9186e 100644 --- a/public/templates/directives/comments.html +++ b/public/templates/directives/comments.html @@ -13,7 +13,7 @@
- +
diff --git a/public/templates/playlists/show.html b/public/templates/playlists/show.html index aa5cb685..8e5713b8 100644 --- a/public/templates/playlists/show.html +++ b/public/templates/playlists/show.html @@ -51,7 +51,7 @@

Description

-

+

Tracks

diff --git a/public/templates/tracks/show.html b/public/templates/tracks/show.html index 7d4539ba..b737d8bf 100644 --- a/public/templates/tracks/show.html +++ b/public/templates/tracks/show.html @@ -71,7 +71,7 @@

Description

-

+

diff --git a/resources/assets/scripts/base/angular-sanitize.js b/resources/assets/scripts/shared/pfm-angular-sanitize.js similarity index 91% rename from resources/assets/scripts/base/angular-sanitize.js rename to resources/assets/scripts/shared/pfm-angular-sanitize.js index 86d2371d..5bd00727 100644 --- a/resources/assets/scripts/base/angular-sanitize.js +++ b/resources/assets/scripts/shared/pfm-angular-sanitize.js @@ -1,4 +1,6 @@ /** + * This is a customized version of ngSanitize for Pony.fm. The linky filter has been updated to the version found in Angular 1.5.0 + * * @license AngularJS v1.2.0 * (c) 2010-2012 Google, Inc. http://angularjs.org * License: MIT @@ -537,41 +539,73 @@ angular.module('ngSanitize', []).value('$sanitize', $sanitize); */ -angular.module('ngSanitize').filter('linky', function() { +function sanitizeText(chars) { + var buf = []; + var writer = htmlSanitizeWriter(buf, angular.noop); + writer.chars(chars); + return buf.join(''); +} + +angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) { var LINKY_URL_REGEXP = - /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>]/, - MAILTO_REGEXP = /^mailto:/; + /((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"\u201d\u2019]/i, + MAILTO_REGEXP = /^mailto:/i; - return function(text, target) { + return function(text, target, attributes) { if (!text) return text; var match; var raw = text; var html = []; - // TODO(vojta): use $sanitize instead - var writer = htmlSanitizeWriter(html); var url; var i; - var properties = {}; - if (angular.isDefined(target)) { - properties.target = target; - } while ((match = raw.match(LINKY_URL_REGEXP))) { // We can not end in these as they are sometimes found at the end of the sentence url = match[0]; - // if we did not match ftp/http/mailto then assume mailto - if (match[2] == match[3]) url = 'mailto:' + url; + // if we did not match ftp/http/www/mailto then assume mailto + if (!match[2] && !match[4]) { + url = (match[3] ? 'http://' : 'mailto:') + url; + } i = match.index; - writer.chars(raw.substr(0, i)); - properties.href = url; - writer.start('a', properties); - writer.chars(match[0].replace(MAILTO_REGEXP, '')); - writer.end('a'); + addText(raw.substr(0, i)); + addLink(url, match[0].replace(MAILTO_REGEXP, '')); raw = raw.substring(i + match[0].length); } - writer.chars(raw); - return html.join(''); + addText(raw); + return $sanitize(html.join('')); + + function addText(text) { + if (!text) { + return; + } + html.push(sanitizeText(text)); + } + + function addLink(url, text) { + var key; + html.push(''); + addText(text); + html.push(''); + } }; -}); +}]); })(window, window.angular); \ No newline at end of file