@@ -632,16 +632,11 @@ impl<'a> IterState<'a> {
632632 Some ( ( _, b'\'' ) ) => b'\'' ,
633633
634634 Some ( ( offset, & q) ) => {
635- if let Some ( q) = self
636- . custom_quotes
637- . iter ( )
638- . find ( |( o, _) | * o == q)
639- . map ( |( _, c) | * c)
640- {
635+ if let Some ( ( _, c) ) = self . custom_quotes . iter ( ) . find ( |( o, _) | * o == q) {
641636 // Input: ` key = q`
642637 // | ^
643638 // offset
644- q
639+ * c
645640 } else {
646641 // Input: ` key = x`
647642 // | ^
@@ -1057,6 +1052,26 @@ mod xml {
10571052 assert_eq ! ( iter. next( ) , None ) ;
10581053 }
10591054
1055+ #[ test]
1056+ fn double_squoted ( ) {
1057+ let mut iter = Attributes :: new_with_custom_quotes (
1058+ r#"tag key=`value()=>} other=`(e) => {}}"# ,
1059+ 3 ,
1060+ & [ ( b'`' , b'}' ) ] ,
1061+ ) ;
1062+
1063+ assert_eq ! (
1064+ iter. next( ) ,
1065+ Some ( Ok ( Attribute {
1066+ key: QName ( b"key" ) ,
1067+ value: Cow :: Borrowed ( b"value()=>" ) ,
1068+ quote: Attr :: CustomQ ( b'`' , b'}' , ( ) , ( ) )
1069+ } ) )
1070+ ) ;
1071+ assert_eq ! ( iter. next( ) , None ) ;
1072+ assert_eq ! ( iter. next( ) , None ) ;
1073+ }
1074+
10601075 /// Attribute have a value enclosed in double quotes
10611076 #[ test]
10621077 fn double_quoted ( ) {
@@ -1082,6 +1097,35 @@ mod xml {
10821097 assert_eq ! ( iter. next( ) , None ) ;
10831098 }
10841099
1100+ /// Attribute have a value enclosed in custom quotes
1101+ #[ test]
1102+ fn custom_quoted ( ) {
1103+ let mut iter = Attributes :: new_with_custom_quotes (
1104+ r#"tag key=`value` regular='attribute'"# ,
1105+ 3 ,
1106+ & [ ( b'`' , b'`' ) ] ,
1107+ ) ;
1108+
1109+ assert_eq ! (
1110+ iter. next( ) ,
1111+ Some ( Ok ( Attribute {
1112+ key: QName ( b"key" ) ,
1113+ value: Cow :: Borrowed ( b"value" ) ,
1114+ quote: Attr :: CustomQ ( b'`' , b'`' , ( ) , ( ) )
1115+ } ) )
1116+ ) ;
1117+ assert_eq ! (
1118+ iter. next( ) ,
1119+ Some ( Ok ( Attribute {
1120+ key: QName ( b"regular" ) ,
1121+ value: Cow :: Borrowed ( b"attribute" ) ,
1122+ quote: Attr :: SingleQ ( ( ) , ( ) )
1123+ } ) )
1124+ ) ;
1125+ assert_eq ! ( iter. next( ) , None ) ;
1126+ assert_eq ! ( iter. next( ) , None ) ;
1127+ }
1128+
10851129 /// Attribute have a value, not enclosed in quotes
10861130 #[ test]
10871131 fn unquoted ( ) {
@@ -1271,6 +1315,24 @@ mod xml {
12711315 assert_eq ! ( iter. next( ) , None ) ;
12721316 }
12731317
1318+ /// Attribute have a value, not enclosed in quotes
1319+ #[ test]
1320+ fn custom_quoted ( ) {
1321+ let mut iter =
1322+ Attributes :: new_with_custom_quotes ( r#"tag key = `value` "# , 3 , & [ ( b'`' , b'`' ) ] ) ;
1323+
1324+ assert_eq ! (
1325+ iter. next( ) ,
1326+ Some ( Ok ( Attribute {
1327+ key: QName ( b"key" ) ,
1328+ value: Cow :: Borrowed ( b"value" ) ,
1329+ quote: Attr :: CustomQ ( b'`' , b'`' , ( ) , ( ) )
1330+ } ) )
1331+ ) ;
1332+ assert_eq ! ( iter. next( ) , None ) ;
1333+ assert_eq ! ( iter. next( ) , None ) ;
1334+ }
1335+
12741336 /// Attribute have a value, not enclosed in quotes
12751337 #[ test]
12761338 fn unquoted ( ) {
0 commit comments