@@ -676,26 +676,26 @@ impl<'s> Parser<'s> {
676
676
chars. next ( ) ;
677
677
if let Some ( ( _, '{' ) ) = chars. next ( ) {
678
678
let end =
679
- start + self . parse_mustache_interpolation ( ) ?. 0 . len ( ) + "{{}}" . len ( ) - 1 ;
679
+ start + self . parse_mustache_interpolation ( ) ?. 0 . len ( ) + "{{}}" . len ( ) ;
680
680
Some ( ( start, end) )
681
681
} else {
682
682
None
683
683
}
684
684
}
685
- Some ( ( _, c) ) if is_attr_name_char ( * c) => {
686
- self . chars . next ( ) . map ( |( start, _) | ( start, start) )
687
- }
685
+ Some ( ( _, c) ) if is_attr_name_char ( * c) => self
686
+ . chars
687
+ . next ( )
688
+ . map ( |( start, c) | ( start, start + c. len_utf8 ( ) ) ) ,
688
689
_ => None ,
689
690
} ) else {
690
691
return Err ( self . emit_error ( SyntaxErrorKind :: ExpectAttrName ) ) ;
691
692
} ;
692
693
693
- while let Some ( ( i , c) ) = self . chars . peek ( ) {
694
+ while let Some ( ( _ , c) ) = self . chars . peek ( ) {
694
695
if is_attr_name_char ( * c) && * c != '{' {
695
- end = * i ;
696
+ end += c . len_utf8 ( ) ;
696
697
self . chars . next ( ) ;
697
698
} else if * c == '{' {
698
- let i = * i;
699
699
let mut chars = self . chars . clone ( ) ;
700
700
chars. next ( ) ;
701
701
match chars. next ( ) {
@@ -705,28 +705,30 @@ impl<'s> Parser<'s> {
705
705
Some ( ( _, '{' ) ) => {
706
706
end += self . parse_mustache_interpolation ( ) ?. 0 . len ( ) + "{{}}" . len ( ) ;
707
707
}
708
- _ => {
709
- end = i ;
708
+ Some ( ( _ , c ) ) => {
709
+ end += c . len_utf8 ( ) ;
710
710
self . chars . next ( ) ;
711
711
}
712
+ None => break ,
712
713
}
713
714
} else {
714
715
break ;
715
716
}
716
717
}
717
718
718
- unsafe { Ok ( self . source . get_unchecked ( start..= end) ) }
719
+ unsafe { Ok ( self . source . get_unchecked ( start..end) ) }
719
720
} else {
720
- let Some ( ( start, _) ) = self . chars . next_if ( |( _, c) | is_attr_name_char ( * c) ) else {
721
+ let Some ( ( start, start_char) ) = self . chars . next_if ( |( _, c) | is_attr_name_char ( * c) )
722
+ else {
721
723
return Err ( self . emit_error ( SyntaxErrorKind :: ExpectAttrName ) ) ;
722
724
} ;
723
- let mut end = start;
725
+ let mut end = start + start_char . len_utf8 ( ) ;
724
726
725
- while let Some ( ( i , _ ) ) = self . chars . next_if ( |( _, c) | is_attr_name_char ( * c) ) {
726
- end = i ;
727
+ while let Some ( ( _ , c ) ) = self . chars . next_if ( |( _, c) | is_attr_name_char ( * c) ) {
728
+ end += c . len_utf8 ( ) ;
727
729
}
728
730
729
- unsafe { Ok ( self . source . get_unchecked ( start..= end) ) }
731
+ unsafe { Ok ( self . source . get_unchecked ( start..end) ) }
730
732
}
731
733
}
732
734
0 commit comments