mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
The domain of data URLs should be null. (#59)
This commit is contained in:
@@ -10,6 +10,10 @@ describe('Utils Service', () => {
|
|||||||
expect(Utils.getDomain('bitwarden')).toBeNull();
|
expect(Utils.getDomain('bitwarden')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fail for data urls', () => {
|
||||||
|
expect(Utils.getDomain('data:image/jpeg;base64,AAA')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle urls without protocol', () => {
|
it('should handle urls without protocol', () => {
|
||||||
expect(Utils.getDomain('bitwarden.com')).toBe('bitwarden.com');
|
expect(Utils.getDomain('bitwarden.com')).toBe('bitwarden.com');
|
||||||
expect(Utils.getDomain('wrong://bitwarden.com')).toBe('bitwarden.com');
|
expect(Utils.getDomain('wrong://bitwarden.com')).toBe('bitwarden.com');
|
||||||
|
|||||||
@@ -182,6 +182,10 @@ export class Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uriString.startsWith('data:')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let httpUrl = uriString.startsWith('http://') || uriString.startsWith('https://');
|
let httpUrl = uriString.startsWith('http://') || uriString.startsWith('https://');
|
||||||
if (!httpUrl && uriString.indexOf('://') < 0 && Utils.tldEndingRegex.test(uriString)) {
|
if (!httpUrl && uriString.indexOf('://') < 0 && Utils.tldEndingRegex.test(uriString)) {
|
||||||
uriString = 'http://' + uriString;
|
uriString = 'http://' + uriString;
|
||||||
|
|||||||
Reference in New Issue
Block a user