This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +13
-5
lines changed Expand file tree Collapse file tree 6 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 66 * Private service to sanitize uris for links and images. Used by $compile and $sanitize.
77 */
88function $$SanitizeUriProvider ( ) {
9- var aHrefSanitizationWhitelist = / ^ \s * ( h t t p s ? | f t p | m a i l t o | t e l | f i l e ) : / ,
9+ var aHrefSanitizationWhitelist = / ^ \s * ( h t t p s ? | s ? f t p | m a i l t o | t e l | f i l e ) : / ,
1010 imgSrcSanitizationWhitelist = / ^ \s * ( ( h t t p s ? | f t p | f i l e | b l o b ) : | d a t a : i m a g e \/ ) / ;
1111
1212 /**
Original file line number Diff line number Diff line change 66 * @kind function
77 *
88 * @description
9- * Finds links in text input and turns them into html links. Supports `http/https/ftp/mailto` and
9+ * Finds links in text input and turns them into html links. Supports `http/https/ftp/sftp/ mailto` and
1010 * plain email address links.
1111 *
1212 * Requires the {@link ngSanitize `ngSanitize`} module to be installed.
129129 */
130130angular . module ( 'ngSanitize' ) . filter ( 'linky' , [ '$sanitize' , function ( $sanitize ) {
131131 var LINKY_URL_REGEXP =
132- / ( ( f t p | h t t p s ? ) : \/ \/ | ( w w w \. ) | ( m a i l t o : ) ? [ A - Z a - z 0 - 9 . _ % + - ] + @ ) \S * [ ^ \s . ; , ( ) { } < > " \u201d \u2019 ] / i,
132+ / ( ( s ? f t p | h t t p s ? ) : \/ \/ | ( w w w \. ) | ( m a i l t o : ) ? [ A - Z a - z 0 - 9 . _ % + - ] + @ ) \S * [ ^ \s . ; , ( ) { } < > " \u201d \u2019 ] / i,
133133 MAILTO_REGEXP = / ^ m a i l t o : / i;
134134
135135 var linkyMinErr = angular . $$minErr ( 'linky' ) ;
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ describe('$compile', function() {
153153
154154 it ( 'should allow aHrefSanitizationWhitelist to be configured' , function ( ) {
155155 module ( function ( $compileProvider ) {
156- expect ( $compileProvider . aHrefSanitizationWhitelist ( ) ) . toEqual ( / ^ \s * ( h t t p s ? | f t p | m a i l t o | t e l | f i l e ) : / ) ; // the default
156+ expect ( $compileProvider . aHrefSanitizationWhitelist ( ) ) . toEqual ( / ^ \s * ( h t t p s ? | s ? f t p | m a i l t o | t e l | f i l e ) : / ) ; // the default
157157 $compileProvider . aHrefSanitizationWhitelist ( / o t h e r / ) ;
158158 expect ( $compileProvider . aHrefSanitizationWhitelist ( ) ) . toEqual ( / o t h e r / ) ;
159159 } ) ;
Original file line number Diff line number Diff line change @@ -216,6 +216,9 @@ describe('sanitizeUri', function() {
216216 testUrl = 'ftp://foo/bar' ;
217217 expect ( sanitizeHref ( testUrl ) ) . toBe ( 'ftp://foo/bar' ) ;
218218
219+ testUrl = 'sftp://foo/bar' ;
220+ expect ( sanitizeHref ( testUrl ) ) . toBe ( 'sftp://foo/bar' ) ;
221+
219222 testUrl = 'mailto:foo@bar.com' ;
220223 expect ( sanitizeHref ( testUrl ) ) . toBe ( 'mailto:foo@bar.com' ) ;
221224
Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ describe('linky', function() {
5858 expect ( linky ( 'HTTP://example.com' ) ) . toEqual ( '<a href="HTTP://example.com">HTTP://example.com</a>' ) ;
5959 expect ( linky ( 'HTTPS://www.example.com' ) ) . toEqual ( '<a href="HTTPS://www.example.com">HTTPS://www.example.com</a>' ) ;
6060 expect ( linky ( 'HTTPS://example.com' ) ) . toEqual ( '<a href="HTTPS://example.com">HTTPS://example.com</a>' ) ;
61+ expect ( linky ( 'FTP://www.example.com' ) ) . toEqual ( '<a href="FTP://www.example.com">FTP://www.example.com</a>' ) ;
62+ expect ( linky ( 'FTP://example.com' ) ) . toEqual ( '<a href="FTP://example.com">FTP://example.com</a>' ) ;
63+ expect ( linky ( 'SFTP://www.example.com' ) ) . toEqual ( '<a href="SFTP://www.example.com">SFTP://www.example.com</a>' ) ;
64+ expect ( linky ( 'SFTP://example.com' ) ) . toEqual ( '<a href="SFTP://example.com">SFTP://example.com</a>' ) ;
6165 } ) ;
6266
6367 it ( 'should handle www.' , function ( ) {
Original file line number Diff line number Diff line change @@ -270,7 +270,8 @@ describe('HTML', function() {
270270
271271 // See https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
272272 it ( 'should not allow JavaScript execution when creating inert document' , inject ( function ( $sanitize ) {
273- var doc = $sanitize ( '<svg><g onload="window.xxx = 100"></g></svg>' ) ;
273+ $sanitize ( '<svg><g onload="window.xxx = 100"></g></svg>' ) ;
274+
274275 expect ( window . xxx ) . toBe ( undefined ) ;
275276 delete window . xxx ;
276277 } ) ) ;
You can’t perform that action at this time.
0 commit comments