@@ -417,11 +417,30 @@ fn cooked_string(input: Cursor) -> Result<Cursor, Reject> {
417
417
Err ( Reject )
418
418
}
419
419
420
+ fn raw_string ( input : Cursor ) -> Result < Cursor , Reject > {
421
+ let ( input, delimiter) = delimiter_of_raw_string ( input) ?;
422
+ let mut chars = input. char_indices ( ) ;
423
+ while let Some ( ( i, ch) ) = chars. next ( ) {
424
+ match ch {
425
+ '"' if input. rest [ i + 1 ..] . starts_with ( delimiter) => {
426
+ let rest = input. advance ( i + 1 + delimiter. len ( ) ) ;
427
+ return Ok ( literal_suffix ( rest) ) ;
428
+ }
429
+ '\r' => match chars. next ( ) {
430
+ Some ( ( _, '\n' ) ) => { }
431
+ _ => break ,
432
+ } ,
433
+ _ => { }
434
+ }
435
+ }
436
+ Err ( Reject )
437
+ }
438
+
420
439
fn byte_string ( input : Cursor ) -> Result < Cursor , Reject > {
421
440
if let Ok ( input) = input. parse ( "b\" " ) {
422
441
cooked_byte_string ( input)
423
442
} else if let Ok ( input) = input. parse ( "br" ) {
424
- raw_string ( input)
443
+ raw_byte_string ( input)
425
444
} else {
426
445
Err ( Reject )
427
446
}
@@ -497,7 +516,7 @@ fn delimiter_of_raw_string(input: Cursor) -> PResult<&str> {
497
516
Ok ( ( input. advance ( n + 1 ) , & input. rest [ ..n] ) )
498
517
}
499
518
500
- fn raw_string ( input : Cursor ) -> Result < Cursor , Reject > {
519
+ fn raw_byte_string ( input : Cursor ) -> Result < Cursor , Reject > {
501
520
let ( input, delimiter) = delimiter_of_raw_string ( input) ?;
502
521
let mut chars = input. char_indices ( ) ;
503
522
while let Some ( ( i, ch) ) = chars. next ( ) {
@@ -510,7 +529,11 @@ fn raw_string(input: Cursor) -> Result<Cursor, Reject> {
510
529
Some ( ( _, '\n' ) ) => { }
511
530
_ => break ,
512
531
} ,
513
- _ => { }
532
+ other => {
533
+ if !other. is_ascii ( ) {
534
+ break ;
535
+ }
536
+ }
514
537
}
515
538
}
516
539
Err ( Reject )
0 commit comments