@@ -43,6 +43,14 @@ class HTMLSmugglingBlocker {
4343 { pattern : / [ ^ \w ] ( \w + ) \s * = \s * ( \w + ) \s * \^ \s * ( \w + ) / i, weight : 2 } ,
4444 { pattern : / \. s l i c e \( \s * \w + \s * - \s * \d + \s * , \s * \w + \s * - \s * \d + \s * \) / i, weight : 2 } ,
4545 { pattern : / f o r \s * \( [ ^ ) ] + \) \s * \{ [ ^ } ] * s t r i n g \. f r o m c h a r c o d e \( [ ^ ) ] + \) / i, weight : 3 } ,
46+ { pattern : / \$ w n d \s * = \s * w i n d o w ; \s * \$ d o c \s * = \s * \$ w n d \. d o c u m e n t / i, weight : 4 } ,
47+ { pattern : / _ _ g w t _ (?: i s K n o w n P r o p e r t y V a l u e | g e t M e t a P r o p e r t y | m a r k e r | s t y l e s L o a d e d | s c r i p t s L o a d e d ) / i, weight : 4 } ,
48+ { pattern : / \$ s t r o n g N a m e \s * = \s * [ ' " ] [ 0 - 9 A - F ] { 32 } [ ' " ] / i, weight : 3 } ,
49+ { pattern : / \$ g w t _ v e r s i o n \s * = \s * [ ' " ] [ 0 - 9 . ] + [ ' " ] / i, weight : 3 } ,
50+ { pattern : / (?: f u n c t i o n | v a r ) \s + [ a - z A - Z $ _ ] + \s * = \s * \{ \s * [ a - z A - Z $ _ ] + : \s * w i n d o w , \s * [ a - z A - Z $ _ ] + : \s * d o c u m e n t \s * \} / i, weight : 4 } ,
51+ { pattern : / \b (?: g w t O n L o a d | _ _ g w t S t a t s E v e n t | g w t O n L o a d F u n c ) \b / i, weight : 3 } ,
52+ { pattern : / \. s e t A t t r i b u t e \( [ ' " ] _ _ g w t _ p r o p e r t y [ ' " ] / i, weight : 3 } ,
53+ { pattern : / d o c u m e n t \. c r e a t e E l e m e n t \( [ ' " ] s c r i p t [ ' " ] \) .* ?\. s r c \s * = .* ?\. c a c h e \. j s / i, weight : 4 }
4654 ] ;
4755 this . threshold = 4 ;
4856 this . cache = new Map ( ) ;
@@ -82,7 +90,8 @@ class HTMLSmugglingBlocker {
8290
8391 getCacheKey ( content ) {
8492 let hash = 0 ;
85- for ( let i = 0 ; i < Math . min ( content . length , 1000 ) ; i ++ ) {
93+ const len = Math . min ( content . length , 500 ) ;
94+ for ( let i = 0 ; i < len ; i ++ ) {
8695 hash = ( ( hash << 5 ) - hash ) + content . charCodeAt ( i ) ;
8796 hash = hash & hash ;
8897 }
0 commit comments