zeroshade commented on code in PR #1259:
URL: https://github.com/apache/iceberg-go/pull/1259#discussion_r3482957498


##########
io/gocloud/azure.go:
##########
@@ -201,21 +201,53 @@ func createAzureBucket(ctx context.Context, parsed 
*url.URL, props map[string]st
        return azureblob.OpenBucket(ctx, client, nil)
 }
 
-// adlsKeyExtractor creates a key extractor for Azure schemes using the 
adlsURIPattern pattern
-func adlsKeyExtractor() KeyExtractor {
-       return func(location string) (string, error) {
+func adlsAuthority(parsed *url.URL) string {
+       if parsed.User == nil {
+               return parsed.Host
+       }
+
+       return parsed.User.String() + "@" + parsed.Host
+}
+
+func adlsObjectLocationExtractor(parsedURL *url.URL, opts 
...keyExtractorOption) objectLocationExtractor {
+       var cfg keyExtractorConfig
+       for _, opt := range opts {
+               opt(&cfg)
+       }
+
+       expectedAuthority := adlsAuthority(parsedURL)
+
+       return func(location string) (objectLocation, error) {
                matches := adlsURIPattern.FindStringSubmatch(location)
                if len(matches) < 4 {
-                       return "", fmt.Errorf("invalid ADLS location: %s", 
location)
+                       return objectLocation{}, fmt.Errorf("invalid ADLS 
location: %s", location)
+               }
+
+               authority := matches[2]
+               if cfg.strictAuthorityValidation && authority != 
expectedAuthority {
+                       return objectLocation{}, fmt.Errorf("URI authority %q 
does not match configured authority %q",
+                               authority, expectedAuthority)
                }
 
                uriPath := matches[3]
                key := strings.TrimPrefix(uriPath, "/")

Review Comment:
   `adlsURIPattern` is `^(abfss?|wasbs?)://([^/?#]+)(.*)?$`, so group 3 
captures everything after the authority *including* a leading `?` or `#`. For 
`abfs://[email protected]?prefix=data`, `uriPath` is 
`?prefix=data` and `key` becomes `?prefix=data` - non-empty, so it's accepted 
as the object key. `splitObjectLocation` now explicitly rejects this shape for 
s3/gs (`must be followed by an object path`), and since `objectLocation()` also 
feeds `WalkDir`, the two paths disagree on the same malformed input. Suggest 
rejecting a non-empty `uriPath` that doesn't begin with `/` here too, to keep 
ADLS consistent with the generic parser (a matching `abfs://...?prefix=data` 
test would lock it in).



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