-
Notifications
You must be signed in to change notification settings - Fork 178
fix: taskrc parser now correctly preserves values containing '=' characters #612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| /// Parses a taskrc file into a Dart [Map]. | ||
| /// Splits each line on the first '=' only, preserving values that | ||
| /// contain '=' characters (e.g. base64-encoded certificates, taskd | ||
| /// parameters with padding). | ||
| Map<String, String> parseTaskrc(String contents) => { | ||
| for (var pair in contents | ||
| for (var line in contents | ||
| .split('\n') | ||
| .where((line) => line.contains('=') && line[0] != '#') | ||
| .map((line) => line.replaceAll('\\/', '/')) // ignore: use_raw_strings | ||
| .map((line) => line.split('='))) | ||
| pair[0].trim(): pair[1].trim(), | ||
| }; | ||
| .map((line) => line.replaceAll('\\/', '/'))) // ignore: use_raw_strings | ||
| line.substring(0, line.indexOf('=')).trim(): | ||
| line.substring(line.indexOf('=') + 1).trim(), | ||
|
||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core bug fix is correct — using
indexOf('=')instead ofsplit('=')properly preserves values containing=characters. However,line.indexOf('=')is called twice on lines 10–11: once to compute the key's end boundary and once to compute the value's start. While the.wherefilter on line 8 guaranteesindexOfwill never return -1, calling it twice is a minor inefficiency and a maintainability concern. A local variable such asfinal sep = line.indexOf('=')should be introduced before the map entry to avoid the repeated call and make the intent clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.