Skip to content

Commit

Permalink
Assert sanitization is strong enough
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Sep 6, 2024
1 parent cb2f89c commit 3a3dfed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ describe('stripTags', () => {
expect(stripTags('<STRONG>foo<STRONG> <strong>bar</strong> <em>baz</em>')).toBe('foo bar baz');
expect(stripTags('foo <br/>bar')).toBe('foo bar');
expect(stripTags('<strong>one</strong> > two > three')).toBe('one > two > three');
expect(stripTags('<scrip<script>is removed</script>t>alert(123)</script>')).toBe('is removedt>alert(123)'); // Broken but safe HTML
expect(stripTags('<!<!--- comment --->>')).toBe('>'); // Broken but safe HTML
expect(stripTags('a<>b')).toBe('ab');
expect(stripTags('a</>b')).toBe('ab');
expect(stripTags('a<>b</>c')).toBe('abc');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export type NaturalSeoConfig = NaturalSeoConfigPlain | Observable<NaturalSeoConf
export const NATURAL_SEO_CONFIG = new InjectionToken<NaturalSeoConfig>('Configuration for SEO service');

export function stripTags(str: string): string {
return str.replace(/<\/?[^>]+>/g, '');
return str.replace(/<\/?[^>]*>/g, '');
}

type Model = {
Expand Down

0 comments on commit 3a3dfed

Please sign in to comment.