vendor/golang.org/x/net/html/token.go
changeset 265 05c40b36d3b2
parent 260 445e01aede7e
equal deleted inserted replaced
264:8f478162d991 265:05c40b36d3b2
   603 		if z.data.end < z.data.start {
   603 		if z.data.end < z.data.start {
   604 			// It's a comment with no data, like <!-->.
   604 			// It's a comment with no data, like <!-->.
   605 			z.data.end = z.data.start
   605 			z.data.end = z.data.start
   606 		}
   606 		}
   607 	}()
   607 	}()
   608 	for dashCount := 2; ; {
   608 
       
   609 	var dashCount int
       
   610 	beginning := true
       
   611 	for {
   609 		c := z.readByte()
   612 		c := z.readByte()
   610 		if z.err != nil {
   613 		if z.err != nil {
   611 			// Ignore up to two dashes at EOF.
   614 			// Ignore up to two dashes at EOF.
   612 			if dashCount > 2 {
   615 			if dashCount > 2 {
   613 				dashCount = 2
   616 				dashCount = 2
   618 		switch c {
   621 		switch c {
   619 		case '-':
   622 		case '-':
   620 			dashCount++
   623 			dashCount++
   621 			continue
   624 			continue
   622 		case '>':
   625 		case '>':
   623 			if dashCount >= 2 {
   626 			if dashCount >= 2 || beginning {
   624 				z.data.end = z.raw.end - len("-->")
   627 				z.data.end = z.raw.end - len("-->")
   625 				return
   628 				return
   626 			}
   629 			}
   627 		case '!':
   630 		case '!':
   628 			if dashCount >= 2 {
   631 			if dashCount >= 2 {
   636 					return
   639 					return
   637 				}
   640 				}
   638 			}
   641 			}
   639 		}
   642 		}
   640 		dashCount = 0
   643 		dashCount = 0
       
   644 		beginning = false
   641 	}
   645 	}
   642 }
   646 }
   643 
   647 
   644 // readUntilCloseAngle reads until the next ">".
   648 // readUntilCloseAngle reads until the next ">".
   645 func (z *Tokenizer) readUntilCloseAngle() {
   649 func (z *Tokenizer) readUntilCloseAngle() {