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 6
6
* Private service to sanitize uris for links and images. Used by $compile and $sanitize.
7
7
*/
8
8
function $$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 ) : / ,
10
10
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 \/ ) / ;
11
11
12
12
/**
Original file line number Diff line number Diff line change 6
6
* @kind function
7
7
*
8
8
* @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
10
10
* plain email address links.
11
11
*
12
12
* Requires the {@link ngSanitize `ngSanitize`} module to be installed.
129
129
*/
130
130
angular . module ( 'ngSanitize' ) . filter ( 'linky' , [ '$sanitize' , function ( $sanitize ) {
131
131
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,
133
133
MAILTO_REGEXP = / ^ m a i l t o : / i;
134
134
135
135
var linkyMinErr = angular . $$minErr ( 'linky' ) ;
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ describe('$compile', function() {
153
153
154
154
it ( 'should allow aHrefSanitizationWhitelist to be configured' , function ( ) {
155
155
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
157
157
$compileProvider . aHrefSanitizationWhitelist ( / o t h e r / ) ;
158
158
expect ( $compileProvider . aHrefSanitizationWhitelist ( ) ) . toEqual ( / o t h e r / ) ;
159
159
} ) ;
Original file line number Diff line number Diff line change @@ -216,6 +216,9 @@ describe('sanitizeUri', function() {
216
216
testUrl = 'ftp://foo/bar' ;
217
217
expect ( sanitizeHref ( testUrl ) ) . toBe ( 'ftp://foo/bar' ) ;
218
218
219
+ testUrl = 'sftp://foo/bar' ;
220
+ expect ( sanitizeHref ( testUrl ) ) . toBe ( 'sftp://foo/bar' ) ;
221
+
219
222
testUrl = 'mailto:foo@bar.com' ;
220
223
expect ( sanitizeHref ( testUrl ) ) . toBe ( 'mailto:foo@bar.com' ) ;
221
224
Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ describe('linky', function() {
58
58
expect ( linky ( 'HTTP://example.com' ) ) . toEqual ( '<a href="HTTP://example.com">HTTP://example.com</a>' ) ;
59
59
expect ( linky ( 'HTTPS://www.example.com' ) ) . toEqual ( '<a href="HTTPS://www.example.com">HTTPS://www.example.com</a>' ) ;
60
60
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>' ) ;
61
65
} ) ;
62
66
63
67
it ( 'should handle www.' , function ( ) {
Original file line number Diff line number Diff line change @@ -270,7 +270,8 @@ describe('HTML', function() {
270
270
271
271
// See https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
272
272
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
+
274
275
expect ( window . xxx ) . toBe ( undefined ) ;
275
276
delete window . xxx ;
276
277
} ) ) ;
You can’t perform that action at this time.
0 commit comments