-
Notifications
You must be signed in to change notification settings - Fork 296
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
Fix panic on invalid globs #820
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vimpostor
added a commit
to vimpostor/tera
that referenced
this pull request
Apr 6, 2023
Regression was introduced in 9479c28. Since that commit providing an invalid glob to tera will make it fail to create an instance, first (in that commit) by making it panic and since 1f95878 by making it return an error. While returning an error is not entirely unlogical, it doesn't match what most languages do with invalid globs. - Bash will by default return an empty set on invalid globs, as the `failglob` option is off by default - Python will likewise return the empty set instead of throwing an exception, when doing something like `glob.glob("/dev/null/*")` - Rust's `globwalk` will also not error, but return an empty set In fact, we use globwalk in tera and the only reason we panic is by accident, because `std::fs::canonicalize()` checks the path. It is better to match other language's glob behaviour, therefore we resort back to the original path if `canonicalize()` fails to return the empty set again when encountering an invalid glob. Even more so, since this caused a lot of regressions already, including in zola. Fixes getzola/zola#2150 ref: Keats#819 ref: Keats#820 ref: Keats#799
vimpostor
added a commit
to vimpostor/tera
that referenced
this pull request
Apr 6, 2023
Regression was introduced in 9479c28. Since that commit, providing an invalid glob to tera will make it fail to create an instance, first (in that commit) by making it panic and since 1f95878 by making it return an error. While returning an error is not entirely unlogical, it doesn't match what most languages do with invalid globs. - Bash will by default return an empty set on invalid globs, as the `failglob` option is off by default - Python will likewise return the empty set instead of throwing an exception, when doing something like `glob.glob("/dev/null/*")` - Rust's `globwalk` will also not error, but return an empty set In fact, we use globwalk in tera and the only reason we panic is by accident, because `std::fs::canonicalize()` checks the path. It is better to match other language's glob behaviour, therefore we resort back to the original path if `canonicalize()` fails to return the empty set again when encountering an invalid glob. We should especially restore the previous behaviour, as this caused a lot of regressions already, including in zola. Fixes getzola/zola#2150 ref: Keats#819 ref: Keats#820 ref: Keats#799
vimpostor
added a commit
to vimpostor/tera
that referenced
this pull request
Apr 6, 2023
Regression was introduced in 9479c28. Since that commit, providing an invalid glob to tera will make it fail to create an instance, first (in that commit) by making it panic and since 1f95878 by making it return an error. While returning an error is not entirely unlogical, it doesn't match what most languages do with invalid globs. - Bash will by default return an empty set on invalid globs, as the `failglob` option is off by default - Python will likewise return the empty set instead of throwing an exception, when doing something like `glob.glob("/dev/null/*")` - Rust's `globwalk` will also not error, but return an empty set In fact, we use globwalk in tera and the only reason we panic is by accident, because `std::fs::canonicalize()` checks the path. It is better to match other language's glob behaviour, therefore we resort back to the original path if `canonicalize()` fails. We should especially restore the previous behaviour, as this caused a lot of regressions already, including in zola. Fixes getzola/zola#2150 ref: Keats#819 ref: Keats#820 ref: Keats#799
vimpostor
added a commit
to vimpostor/tera
that referenced
this pull request
Apr 10, 2023
Regression was introduced in 9479c28. Since that commit, providing an invalid glob to tera will make it fail to create an instance, first (in that commit) by making it panic and since 1f95878 by making it return an error. While returning an error is not entirely unlogical, it doesn't match what most languages do with invalid globs. - Bash will by default return an empty set on invalid globs, as the `failglob` option is off by default - Python will likewise return the empty set instead of throwing an exception, when doing something like `glob.glob("/dev/null/*")` - Rust's `globwalk` will also not error, but return an empty set In fact, we use globwalk in tera and the only reason we panic is by accident, because `std::fs::canonicalize()` checks the path. It is better to match other language's glob behaviour, therefore we resort back to the original path if `canonicalize()` fails. We should especially restore the previous behaviour, as this caused a lot of regressions already, including in zola. Fixes getzola/zola#2150 ref: Keats#819 ref: Keats#820 ref: Keats#799
Keats
pushed a commit
that referenced
this pull request
Apr 16, 2023
Regression was introduced in 9479c28. Since that commit, providing an invalid glob to tera will make it fail to create an instance, first (in that commit) by making it panic and since 1f95878 by making it return an error. While returning an error is not entirely unlogical, it doesn't match what most languages do with invalid globs. - Bash will by default return an empty set on invalid globs, as the `failglob` option is off by default - Python will likewise return the empty set instead of throwing an exception, when doing something like `glob.glob("/dev/null/*")` - Rust's `globwalk` will also not error, but return an empty set In fact, we use globwalk in tera and the only reason we panic is by accident, because `std::fs::canonicalize()` checks the path. It is better to match other language's glob behaviour, therefore we resort back to the original path if `canonicalize()` fails. We should especially restore the previous behaviour, as this caused a lot of regressions already, including in zola. Fixes getzola/zola#2150 ref: #819 ref: #820 ref: #799
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #819