@@ -306,6 +306,7 @@ def handleMeta(self):
306
306
elif attr [0 ] == "content" :
307
307
contentParser = ContentAttrParser (attr [1 ])
308
308
tentativeEncoding = contentParser .parse ()
309
+ self .position += contentParser .position
309
310
if isValidEncoding (tentativeEncoding ):
310
311
self .encoding = tentativeEncoding
311
312
return False
@@ -404,10 +405,10 @@ def parse(self):
404
405
if self .fragment [self .position ] in ('"' , "'" ):
405
406
quoteMark = self .fragment [self .position ]
406
407
self .position += 1
407
- oldPosition = self .positon
408
- endQuotePosition = selfBytes (quoteMark )
409
- if endQuotePosition > - 1 :
410
- return value [ position : position + endQuotePosition ]
408
+ oldPosition = self .position
409
+ self . findNext (quoteMark )
410
+ if self . position < len ( self . fragment ) :
411
+ return self . fragment [ oldPosition : self . position ]
411
412
else :
412
413
self .position = oldPosition
413
414
#No matching end quote => no charset
@@ -439,7 +440,7 @@ def parse(self):
439
440
#Step 5 attribute name
440
441
while True :
441
442
if self .position == len (self .fragment ):
442
- return "" . join ( attrName ), ""
443
+ return None
443
444
elif self .fragment [self .position ] == "=" and attrName :
444
445
break
445
446
elif self .fragment [self .position ] in spaceCharacters :
@@ -461,7 +462,7 @@ def parse(self):
461
462
return "" .join (attrName ), ""
462
463
#Step 8
463
464
if self .fragment [self .position ] != "=" :
464
- # self.position -= 1
465
+ self .position -= 1
465
466
return "" .join (attrName ), ""
466
467
#XXX need to advance positon in both spaces and value case
467
468
#Step 9
@@ -470,7 +471,7 @@ def parse(self):
470
471
self .skip ()
471
472
#XXX Need to exit if we go past the end of the fragment
472
473
if self .position == len (self .fragment ):
473
- return "" . join ( attrName ), ""
474
+ return None
474
475
#Step 11
475
476
if self .fragment [self .position ] in ("'" , '"' ):
476
477
#11.1
@@ -479,10 +480,9 @@ def parse(self):
479
480
#11.2
480
481
self .position += 1
481
482
if self .position == len (self .fragment ):
482
- return "" . join ( attrName ), "" . join ( attrValue )
483
+ return None
483
484
#11.3
484
485
elif self .fragment [self .position ] == quoteChar :
485
- #XXX Not in spec
486
486
self .position += 1
487
487
return "" .join (attrName ), "" .join (attrValue )
488
488
#11.4
@@ -492,21 +492,17 @@ def parse(self):
492
492
else :
493
493
attrValue .extend (self .fragment [self .position ])
494
494
elif self .fragment [self .position ] in (">" , '<' ):
495
- #self.position -= 1
496
495
return "" .join (attrName ), ""
497
496
elif self .fragment [self .position ] in asciiUppercase :
498
497
attrValue .extend (self .fragment [self .position ].lower ())
499
498
else :
500
499
attrValue .extend (self .fragment [self .position ])
501
- #XXX I think this next bit is right but there is a bug in the spec
502
500
while True :
503
501
self .position += 1
504
502
if self .position == len (self .fragment ):
505
- return "" . join ( attrName ), "" . join ( attrValue )
503
+ return None
506
504
elif self .fragment [self .position ] in (
507
505
list (spaceCharacters ) + [">" , '<' ]):
508
- #XXX this is wrong
509
- #self.position -= 1
510
506
return "" .join (attrName ), "" .join (attrValue )
511
507
elif self .fragment [self .position ] in asciiUppercase :
512
508
attrValue .extend (self .fragment [self .position ].lower ())
0 commit comments