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


##########
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:
   Fixed in 69e69f377. The SDK checks a bucket without dots against 
`[a-z\d][a-z\d\-]{1,61}[a-z\d]` first, and that allows `--`, so the IPv4 and 
adjacent-separator checks now apply only to dotted names. Those still follow 
the dotted rule, which rejects `[.-]{2}`, so `a--b.c` over HTTP stays 
path-style as it does in the SDK. `a--b` is in the final-URL test now, and a 
small table test covers `a--b`, `a.-b`, `a-.b`, `a..b` and `a--b.c`.
   



-- 
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