From a4afad99a1dbcfc37521c6534692104e9557b0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conny=20Sj=C3=B6blom?= Date: Wed, 10 Jun 2015 13:42:10 +0300 Subject: [PATCH 1/3] Modified not to be case sensitive Fixes #12073 --- src/ngSanitize/filter/linky.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ngSanitize/filter/linky.js b/src/ngSanitize/filter/linky.js index e0be704f9c2c..04c7d0402b55 100644 --- a/src/ngSanitize/filter/linky.js +++ b/src/ngSanitize/filter/linky.js @@ -104,8 +104,8 @@ */ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) { var LINKY_URL_REGEXP = - /((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"”’]/, - MAILTO_REGEXP = /^mailto:/; + /((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"”’]/i, + MAILTO_REGEXP = /^mailto:/i; return function(text, target) { if (!text) return text; From b3f0c4225c77c09bbbca1f4e9bdb8a7a9f135c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conny=20Sj=C3=B6blom?= Date: Wed, 10 Jun 2015 15:16:47 +0300 Subject: [PATCH 2/3] Test cases added --- test/ngSanitize/filter/linkySpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/ngSanitize/filter/linkySpec.js b/test/ngSanitize/filter/linkySpec.js index baac45bd6d82..f0c4f3956e54 100644 --- a/test/ngSanitize/filter/linkySpec.js +++ b/test/ngSanitize/filter/linkySpec.js @@ -20,6 +20,15 @@ describe('linky', function() { expect(linky(undefined)).not.toBeDefined(); }); + it('should be case-insensitive', function() { + expect(linky('WWW.example.com')).toEqual('WWW.example.com'); + expect(linky('WWW.EXAMPLE.COM')).toEqual('WWW.EXAMPLE.COM'); + expect(linky('HTTP://www.example.com')).toEqual('HTTP://www.example.com'); + expect(linky('HTTP://example.com')).toEqual('HTTP://example.com'); + expect(linky('HTTPS://www.example.com')).toEqual('HTTPS://www.example.com'); + expect(linky('HTTPS://example.com')).toEqual('HTTPS://example.com'); + }); + it('should handle www.', function() { expect(linky('www.example.com')).toEqual('www.example.com'); }); From 1f3261819503cf235f3c31cbaa6916a3f496a29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conny=20Sj=C3=B6blom?= Date: Wed, 10 Jun 2015 15:16:47 +0300 Subject: [PATCH 3/3] Test cases added --- test/ngSanitize/filter/linkySpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/ngSanitize/filter/linkySpec.js b/test/ngSanitize/filter/linkySpec.js index baac45bd6d82..f0c4f3956e54 100644 --- a/test/ngSanitize/filter/linkySpec.js +++ b/test/ngSanitize/filter/linkySpec.js @@ -20,6 +20,15 @@ describe('linky', function() { expect(linky(undefined)).not.toBeDefined(); }); + it('should be case-insensitive', function() { + expect(linky('WWW.example.com')).toEqual('WWW.example.com'); + expect(linky('WWW.EXAMPLE.COM')).toEqual('WWW.EXAMPLE.COM'); + expect(linky('HTTP://www.example.com')).toEqual('HTTP://www.example.com'); + expect(linky('HTTP://example.com')).toEqual('HTTP://example.com'); + expect(linky('HTTPS://www.example.com')).toEqual('HTTPS://www.example.com'); + expect(linky('HTTPS://example.com')).toEqual('HTTPS://example.com'); + }); + it('should handle www.', function() { expect(linky('www.example.com')).toEqual('www.example.com'); });