Skip to content

Commit

Permalink
Revert "Merge pull request #386 from ziflow/master"
Browse files Browse the repository at this point in the history
This reverts commit 8119d5c, reversing
changes made to b0c15d6.
  • Loading branch information
gregjacobs committed Sep 7, 2022
1 parent e518a70 commit 2e1f211
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
12 changes: 0 additions & 12 deletions src/autolinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,6 @@ export default class Autolinker {
textOrHtml = textOrHtml.replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

textOrHtml = this.stripUnsafeCharacters(textOrHtml);

let matches = this.parse(textOrHtml),
newHtml: string[] = [],
lastIndex = 0;
Expand Down Expand Up @@ -1022,16 +1020,6 @@ export default class Autolinker {

return tagBuilder;
}

/**
* Strips characters considered as unsafe
* SNYK-AUTOLINKER-2438289
* @param text
* @private
*/
private stripUnsafeCharacters(text: string) {
return text.replace(/[\u202a-\u202e\u200e-\u200f]/g, '');
}
}

export interface AutolinkerConfig {
Expand Down
26 changes: 0 additions & 26 deletions tests/autolinker-url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1265,30 +1265,4 @@ describe('Autolinker Url Matching -', () => {
);
});
});

describe('unicode exploits', () => {
it('should strip out character direction override unicodes which could split links into two (https://github.com/gregjacobs/Autolinker.js/issues/377)', () => {
expect(autolinker.link('foo.combar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
expect(autolinker.link('foo.com\u202Ebar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
expect(autolinker.link('foo.com\u202abar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
expect(autolinker.link('foo.com\u202bbar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
expect(autolinker.link('foo.com\u202cbar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
expect(autolinker.link('foo.com\u202dbar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
expect(autolinker.link('foo.com\u202ebar.com')).toBe(
'<a href="http://foo.combar.com">foo.combar.com</a>'
);
});
});
});

0 comments on commit 2e1f211

Please sign in to comment.