Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(sanitize): match URI schemes case-insensitively
Browse files Browse the repository at this point in the history
According to RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
schemes such as http or mailto are case-insensitive. So links such as
http://server/ and HTTP://server/ are valid and equivalent.

Closes #3210
  • Loading branch information
petebacondarwin committed Jul 12, 2013
1 parent 3371fc2 commit 7fef06f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ngSanitize/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var START_TAG_REGEXP = /^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:
BEGING_END_TAGE_REGEXP = /^<\s*\//,
COMMENT_REGEXP = /<!--(.*?)-->/g,
CDATA_REGEXP = /<!\[CDATA\[(.*?)]]>/g,
URI_REGEXP = /^((ftp|https?):\/\/|mailto:|tel:|#)/,
URI_REGEXP = /^((ftp|https?):\/\/|mailto:|tel:|#)/i,
NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g; // Match everything outside of normal chars and " (quote character)


Expand Down
5 changes: 5 additions & 0 deletions test/ngSanitize/sanitizeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ describe('HTML', function() {

it('should be URI', function() {
expect(isUri('http://abc')).toBeTruthy();
expect(isUri('HTTP://abc')).toBeTruthy();
expect(isUri('https://abc')).toBeTruthy();
expect(isUri('HTTPS://abc')).toBeTruthy();
expect(isUri('ftp://abc')).toBeTruthy();
expect(isUri('FTP://abc')).toBeTruthy();
expect(isUri('mailto:me@example.com')).toBeTruthy();
expect(isUri('MAILTO:me@example.com')).toBeTruthy();
expect(isUri('tel:123-123-1234')).toBeTruthy();
expect(isUri('TEL:123-123-1234')).toBeTruthy();
expect(isUri('#anchor')).toBeTruthy();
});

Expand Down

0 comments on commit 7fef06f

Please sign in to comment.