File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,6 +97,30 @@ describe('SVG Sanitizer Utilities', () => {
9797 it ( 'returns null for completely invalid font' , ( ) => {
9898 expect ( sanitizeFont ( '!!!' ) ) . toBe ( null ) ;
9999 } ) ;
100+
101+ it ( 'returns null for null input' , ( ) => {
102+ expect ( sanitizeFont ( null ) ) . toBe ( null ) ;
103+ } ) ;
104+
105+ it ( 'returns null for whitespace-only input' , ( ) => {
106+ expect ( sanitizeFont ( ' ' ) ) . toBe ( null ) ;
107+ } ) ;
108+
109+ it ( 'preserves valid font names with spaces' , ( ) => {
110+ expect ( sanitizeFont ( 'Fira Code' ) ) . toBe ( 'Fira Code' ) ;
111+ } ) ;
112+
113+ it ( 'allows numeric font names' , ( ) => {
114+ expect ( sanitizeFont ( '123' ) ) . toBe ( '123' ) ;
115+ } ) ;
116+
117+ it ( 'sanitizes script injection attempts' , ( ) => {
118+ expect ( sanitizeFont ( '<script>alert(1)</script>' ) ) . toBe ( 'scriptalert1script' ) ;
119+ } ) ;
120+
121+ it ( 'returns null when sanitization removes all characters' , ( ) => {
122+ expect ( sanitizeFont ( '@@@' ) ) . toBe ( null ) ;
123+ } ) ;
100124 } ) ;
101125
102126 describe ( 'sanitizeGoogleFontUrl' , ( ) => {
You can’t perform that action at this time.
0 commit comments