@@ -180,7 +180,7 @@ def get_starttag_text(self):
180180 def set_cdata_mode (self , elem , * , escapable = False ):
181181 self .cdata_elem = elem .lower ()
182182 self ._escapable = escapable
183- if escapable is None : # PLAINTEXT mode
183+ if self . cdata_elem == 'plaintext' :
184184 self .interesting = re .compile (r'\z' )
185185 elif escapable and not self .convert_charrefs :
186186 self .interesting = re .compile (r'&|</%s(?=[\t\n\r\f />])' % self .cdata_elem ,
@@ -454,14 +454,12 @@ def parse_starttag(self, i):
454454 self .handle_startendtag (tag , attrs )
455455 else :
456456 self .handle_starttag (tag , attrs )
457- if tag in self .CDATA_CONTENT_ELEMENTS :
458- self .set_cdata_mode (tag )
457+ if (tag in self .CDATA_CONTENT_ELEMENTS or
458+ (self .scripting and tag == "noscript" ) or
459+ tag == "plaintext" ):
460+ self .set_cdata_mode (tag , escapable = False )
459461 elif tag in self .RCDATA_CONTENT_ELEMENTS :
460462 self .set_cdata_mode (tag , escapable = True )
461- elif self .scripting and tag == "noscript" :
462- self .set_cdata_mode (tag )
463- elif tag == "plaintext" :
464- self .set_cdata_mode (tag , escapable = None )
465463 return endpos
466464
467465 # Internal -- check to see if we have a complete starttag; return end
0 commit comments