sunchao commented on code in PR #5872:
URL: https://github.com/apache/datafusion-comet/pull/5872#discussion_r4433048460


##########
native/core/src/parquet/objectstore/s3.rs:
##########
@@ -384,11 +403,42 @@ fn extract_s3_config_options(
     s3_configs
 }
 
+/// Mirrors the AWS SDK's `isVirtualHostableS3Bucket`: 3 to 63 lowercase 
letters, digits and
+/// hyphens that start and end with a letter or digit. Dots only over plain 
HTTP, since a dotted
+/// host falls outside S3's wildcard certificate, and then no IPv4 shape or 
adjacent separators.
+fn is_virtual_hostable_bucket(bucket: &str, allow_dots: bool) -> bool {
+    let bytes = bucket.as_bytes();
+    let edge = |b: &u8| b.is_ascii_lowercase() || b.is_ascii_digit();
+    let inner = |b: &u8| edge(b) || *b == b'-' || (allow_dots && *b == b'.');
+    if !(3..=63).contains(&bytes.len())
+        || !bytes.first().is_some_and(edge)
+        || !bytes.last().is_some_and(edge)
+        || !bytes.iter().all(inner)
+    {
+        return false;
+    }
+    let ipv4_shaped = bucket.split('.').count() == 4
+        && bucket
+            .split('.')
+            .all(|label| label.bytes().all(|b| b.is_ascii_digit()));
+    let separators_touch = bytes
+        .windows(2)
+        .any(|pair| pair.iter().all(|b| *b == b'.' || *b == b'-'));

Review Comment:
   For bucket `a--b`, endpoint `http://storage.example.test`, and path-style 
disabled, the AWS SDK 2.31.51 endpoint provider returns 
`http://a--b.storage.example.test`. This predicate also rejects adjacent 
hyphens, so Comet instead requests `http://storage.example.test/a--b`. That 
changes routing on a virtual-host-only endpoint. Could the separator check 
allow `--` and add this case to the final-URL tests?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to