@@ -289,23 +289,41 @@ impl Parse for Meta<Identifier> {
289
289
/// ```
290
290
impl Parse for UserSpecifier {
291
291
fn parse ( stream : & mut CharStream ) -> Parsed < Self > {
292
- let userspec = if stream. eat_char ( '%' ) {
293
- let ctor = if stream. eat_char ( ':' ) {
294
- UserSpecifier :: NonunixGroup
292
+ fn parse_user ( stream : & mut CharStream ) -> Parsed < UserSpecifier > {
293
+ let userspec = if stream. eat_char ( '%' ) {
294
+ let ctor = if stream. eat_char ( ':' ) {
295
+ UserSpecifier :: NonunixGroup
296
+ } else {
297
+ UserSpecifier :: Group
298
+ } ;
299
+ // in this case we must fail 'hard', since input has been consumed
300
+ ctor ( expect_nonterminal ( stream) ?)
301
+ } else if stream. eat_char ( '+' ) {
302
+ // TODO Netgroups
303
+ unrecoverable ! ( stream, "netgroups are not supported yet" ) ;
295
304
} else {
296
- UserSpecifier :: Group
305
+ // in this case we must fail 'softly', since no input has been consumed yet
306
+ UserSpecifier :: User ( try_nonterminal ( stream) ?)
297
307
} ;
298
- // in this case we must fail 'hard', since input has been consumed
299
- ctor ( expect_nonterminal ( stream) ?)
300
- } else if stream. eat_char ( '+' ) {
301
- // TODO Netgroups
302
- unrecoverable ! ( stream, "netgroups are not supported yet" ) ;
303
- } else {
304
- // in this case we must fail 'softly', since no input has been consumed yet
305
- UserSpecifier :: User ( try_nonterminal ( stream) ?)
306
- } ;
307
308
308
- make ( userspec)
309
+ make ( userspec)
310
+ }
311
+
312
+ // if we see a quote, first parse the quoted text as a token and then
313
+ // re-parse whatever we found inside; this is a lazy solution but it works
314
+ let begin_pos = stream. get_pos ( ) ;
315
+ if stream. eat_char ( '"' ) {
316
+ let Unquoted ( text, _) : Unquoted < Username > = expect_nonterminal ( stream) ?;
317
+ let result = parse_user ( & mut CharStream :: new ( text. chars ( ) ) ) ;
318
+ if result. is_err ( ) {
319
+ unrecoverable ! ( pos = begin_pos, stream, "invalid user" )
320
+ }
321
+ expect_syntax ( '"' , stream) ?;
322
+
323
+ result
324
+ } else {
325
+ parse_user ( stream)
326
+ }
309
327
}
310
328
}
311
329
@@ -570,7 +588,7 @@ impl Parse for Sudo {
570
588
fn parse_include ( stream : & mut CharStream ) -> Parsed < Sudo > {
571
589
fn get_path ( stream : & mut CharStream , key_pos : ( usize , usize ) ) -> Parsed < ( String , Span ) > {
572
590
let path = if stream. eat_char ( '"' ) {
573
- let QuotedInclude ( path) = expect_nonterminal ( stream) ?;
591
+ let QuotedIncludePath ( path) = expect_nonterminal ( stream) ?;
574
592
expect_syntax ( '"' , stream) ?;
575
593
path
576
594
} else {
@@ -744,7 +762,7 @@ impl Parse for defaults::SettingsModifier {
744
762
// Parse a text parameter
745
763
let text_item = |stream : & mut CharStream | {
746
764
if stream. eat_char ( '"' ) {
747
- let QuotedText ( text) = expect_nonterminal ( stream) ?;
765
+ let QuotedStringParameter ( text) = expect_nonterminal ( stream) ?;
748
766
expect_syntax ( '"' , stream) ?;
749
767
make ( text)
750
768
} else {
0 commit comments