@@ -417,11 +417,30 @@ fn cooked_string(input: Cursor) -> Result<Cursor, Reject> {
417417 Err ( Reject )
418418}
419419
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+
420439fn byte_string ( input : Cursor ) -> Result < Cursor , Reject > {
421440 if let Ok ( input) = input. parse ( "b\" " ) {
422441 cooked_byte_string ( input)
423442 } else if let Ok ( input) = input. parse ( "br" ) {
424- raw_string ( input)
443+ raw_byte_string ( input)
425444 } else {
426445 Err ( Reject )
427446 }
@@ -497,7 +516,7 @@ fn delimiter_of_raw_string(input: Cursor) -> PResult<&str> {
497516 Ok ( ( input. advance ( n + 1 ) , & input. rest [ ..n] ) )
498517}
499518
500- fn raw_string ( input : Cursor ) -> Result < Cursor , Reject > {
519+ fn raw_byte_string ( input : Cursor ) -> Result < Cursor , Reject > {
501520 let ( input, delimiter) = delimiter_of_raw_string ( input) ?;
502521 let mut chars = input. char_indices ( ) ;
503522 while let Some ( ( i, ch) ) = chars. next ( ) {
@@ -510,7 +529,11 @@ fn raw_string(input: Cursor) -> Result<Cursor, Reject> {
510529 Some ( ( _, '\n' ) ) => { }
511530 _ => break ,
512531 } ,
513- _ => { }
532+ other => {
533+ if !other. is_ascii ( ) {
534+ break ;
535+ }
536+ }
514537 }
515538 }
516539 Err ( Reject )
0 commit comments