@@ -306,6 +306,7 @@ def handleMeta(self):
306306 elif attr [0 ] == "content" :
307307 contentParser = ContentAttrParser (attr [1 ])
308308 tentativeEncoding = contentParser .parse ()
309+ self .position += contentParser .position
309310 if isValidEncoding (tentativeEncoding ):
310311 self .encoding = tentativeEncoding
311312 return False
@@ -404,10 +405,10 @@ def parse(self):
404405 if self .fragment [self .position ] in ('"' , "'" ):
405406 quoteMark = self .fragment [self .position ]
406407 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 ]
411412 else :
412413 self .position = oldPosition
413414 #No matching end quote => no charset
@@ -439,7 +440,7 @@ def parse(self):
439440 #Step 5 attribute name
440441 while True :
441442 if self .position == len (self .fragment ):
442- return "" . join ( attrName ), ""
443+ return None
443444 elif self .fragment [self .position ] == "=" and attrName :
444445 break
445446 elif self .fragment [self .position ] in spaceCharacters :
@@ -461,7 +462,7 @@ def parse(self):
461462 return "" .join (attrName ), ""
462463 #Step 8
463464 if self .fragment [self .position ] != "=" :
464- # self.position -= 1
465+ self .position -= 1
465466 return "" .join (attrName ), ""
466467 #XXX need to advance positon in both spaces and value case
467468 #Step 9
@@ -470,7 +471,7 @@ def parse(self):
470471 self .skip ()
471472 #XXX Need to exit if we go past the end of the fragment
472473 if self .position == len (self .fragment ):
473- return "" . join ( attrName ), ""
474+ return None
474475 #Step 11
475476 if self .fragment [self .position ] in ("'" , '"' ):
476477 #11.1
@@ -479,10 +480,9 @@ def parse(self):
479480 #11.2
480481 self .position += 1
481482 if self .position == len (self .fragment ):
482- return "" . join ( attrName ), "" . join ( attrValue )
483+ return None
483484 #11.3
484485 elif self .fragment [self .position ] == quoteChar :
485- #XXX Not in spec
486486 self .position += 1
487487 return "" .join (attrName ), "" .join (attrValue )
488488 #11.4
@@ -492,21 +492,17 @@ def parse(self):
492492 else :
493493 attrValue .extend (self .fragment [self .position ])
494494 elif self .fragment [self .position ] in (">" , '<' ):
495- #self.position -= 1
496495 return "" .join (attrName ), ""
497496 elif self .fragment [self .position ] in asciiUppercase :
498497 attrValue .extend (self .fragment [self .position ].lower ())
499498 else :
500499 attrValue .extend (self .fragment [self .position ])
501- #XXX I think this next bit is right but there is a bug in the spec
502500 while True :
503501 self .position += 1
504502 if self .position == len (self .fragment ):
505- return "" . join ( attrName ), "" . join ( attrValue )
503+ return None
506504 elif self .fragment [self .position ] in (
507505 list (spaceCharacters ) + [">" , '<' ]):
508- #XXX this is wrong
509- #self.position -= 1
510506 return "" .join (attrName ), "" .join (attrValue )
511507 elif self .fragment [self .position ] in asciiUppercase :
512508 attrValue .extend (self .fragment [self .position ].lower ())
0 commit comments