File tree 1 file changed +8
-0
lines changed
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -457,6 +457,10 @@ def processStartTag(self, token):
457
457
func = self .__startTagCache [name ]
458
458
except KeyError :
459
459
func = self .__startTagCache [name ] = self .startTagHandler [name ]
460
+ # bound the cache size in case we get loads of unknown tags
461
+ while len (self .__startTagCache ) > len (self .startTagHandler ) * 1.1 :
462
+ # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
463
+ self .__startTagCache .pop (next (iter (self .__startTagCache )))
460
464
return func (token )
461
465
462
466
def startTagHtml (self , token ):
@@ -475,6 +479,10 @@ def processEndTag(self, token):
475
479
func = self .__endTagCache [name ]
476
480
except KeyError :
477
481
func = self .__endTagCache [name ] = self .endTagHandler [name ]
482
+ # bound the cache size in case we get loads of unknown tagss
483
+ while len (self .__endTagCache ) > len (self .endTagHandler ) * 1.1 :
484
+ # this makes the eviction policy random on Py < 3.7 and FIFO >= 3.7
485
+ self .__endTagCache .pop (next (iter (self .__endTagCache )))
478
486
return func (token )
479
487
480
488
class InitialPhase (Phase ):
You can’t perform that action at this time.
0 commit comments