@@ -14,6 +14,18 @@ def any(iterable):
14
14
if element :
15
15
return True
16
16
return False
17
+
18
+ try :
19
+ "abc" .startswith (("a" , "b" ))
20
+ def startswithany (str , prefixes ):
21
+ return str .startswith (prefixes )
22
+ except :
23
+ # Python 2.4 doesn't accept a tuple as argument to string startswith
24
+ def startswithany (str , prefixes ):
25
+ for prefix in prefixes :
26
+ if str .startswith (prefix ):
27
+ return True
28
+ return False
17
29
18
30
import sys
19
31
@@ -485,7 +497,7 @@ def processDoctype(self, token):
485
497
publicId = publicId .translate (asciiUpper2Lower )
486
498
487
499
if (not correct or token ["name" ] != "html"
488
- or publicId . startswith (
500
+ or startswithany ( publicId ,
489
501
("+//silmaril//dtd html pro v0r11 19970101//" ,
490
502
"-//advasoft ltd//dtd html 3.0 aswedit + extensions//" ,
491
503
"-//as//dtd html 3.0 aswedit + extensions//" ,
@@ -545,16 +557,16 @@ def processDoctype(self, token):
545
557
("-//w3o//dtd w3 html strict 3.0//en//" ,
546
558
"-/w3c/dtd html 4.0 transitional/en" ,
547
559
"html" )
548
- or publicId . startswith (
560
+ or startswithany ( publicId ,
549
561
("-//w3c//dtd html 4.01 frameset//" ,
550
562
"-//w3c//dtd html 4.01 transitional//" )) and
551
563
systemId == None
552
564
or systemId and systemId .lower () == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd" ):
553
565
self .parser .compatMode = "quirks"
554
- elif (publicId . startswith (
566
+ elif (startswithany ( publicId ,
555
567
("-//w3c//dtd xhtml 1.0 frameset//" ,
556
568
"-//w3c//dtd xhtml 1.0 transitional//" ))
557
- or publicId . startswith (
569
+ or startswithany ( publicId ,
558
570
("-//w3c//dtd html 4.01 frameset//" ,
559
571
"-//w3c//dtd html 4.01 transitional//" )) and
560
572
systemId != None ):
0 commit comments