-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 ListingTableUrl
to decode percent
#3750
Changes from 2 commits
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 |
---|---|---|
|
@@ -24,6 +24,7 @@ use itertools::Itertools; | |
use object_store::path::Path; | ||
use object_store::{ObjectMeta, ObjectStore}; | ||
use url::Url; | ||
use percent_encoding; | ||
|
||
/// A parsed URL identifying files for a listing table, see [`ListingTableUrl::parse`] | ||
/// for more information on the supported expressions | ||
|
@@ -108,7 +109,8 @@ impl ListingTableUrl { | |
|
||
/// Creates a new [`ListingTableUrl`] from a url and optional glob expression | ||
fn new(url: Url, glob: Option<Pattern>) -> Self { | ||
let prefix = Path::parse(url.path()).expect("should be URL safe"); | ||
let decoded_path = percent_encoding::percent_decode_str(url.path()).decode_utf8_lossy(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will cause the parse call below to fail in the event of non-ASCII characters. I think it should just be a case of change |
||
let prefix = Path::parse(decoded_path).expect("should be URL safe"); | ||
Self { url, prefix, glob } | ||
} | ||
|
||
|
@@ -246,6 +248,9 @@ mod tests { | |
let url = ListingTableUrl::parse("file:///foo").unwrap(); | ||
let child = Path::parse("/foob/bar").unwrap(); | ||
assert!(url.strip_prefix(&child).is_none()); | ||
|
||
let url = ListingTableUrl::parse("file:///with space/foo/bar").unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we get a test of a non-ASCII character such as a percent encoded emoji or something We should also test non-URL safe characters like a percent encoded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I added some test cases at 439f6dc |
||
assert_eq!(url.prefix.as_ref(), "with space/foo/bar"); | ||
} | ||
|
||
#[test] | ||
|
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.
datafusion/core
usesurl
crate by servo.percent-encoding
is also published by the same repository.