xylaaaaa opened a new issue, #69645:
URL: https://github.com/apache/doris/issues/69645

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### Version
   
   master (8d2bd1e14b6)
   
   ### What's Wrong?
   
   Reading an Azure Blob object through an `https://` location whose path 
contains a percent-encoded `+` (`%2B`) reads a **different** object: the one 
whose name has a space in that position. No error is reported, so the query 
silently returns the wrong data.
   
   Example, in container `c` of account `acct`:
   
   | Object | Content |
   | --- | --- |
   | `a+b/1/a.csv` | `21` |
   | `a b/1/a.csv` | `91` |
   
   ```sql
   SELECT * FROM s3(
       'uri' = 'https://acct.blob.core.windows.net/c/a%2Bb/1/a.csv',
       'format' = 'csv',
       'provider' = 'azure',
       'azure.account_name' = 'acct',
       'azure.account_key' = '...');
   -- returns 91 (the content of "a b/1/a.csv"), expected 21
   ```
   
   The same happens with a glob over an encoded HTTPS path (e.g. 
`https://.../c/a%2Bb/*/a.csv`), and with SharedKey, SAS and OAuth2 credentials 
alike. The `s3://c/a%2Bb/1/a.csv` form, HTTPS `%20` and HTTPS `%252B` read the 
expected objects.
   
   ### What You Expected?
   
   `https://acct.blob.core.windows.net/c/a%2Bb/1/a.csv` reads `a+b/1/a.csv`, 
the same object as `abfss://[email protected]/a%2Bb/1/a.csv` and 
`s3://c/a%2Bb/1/a.csv`.
   
   ### How to Reproduce?
   
   1. In an Azure Blob container, upload `a+b/1/a.csv` with content `21` and `a 
b/1/a.csv` with content `91`.
   2. Run the `s3()` query above with the `https://` URI containing `%2B`.
   3. The result is `91` instead of `21`.
   
   ### Anything Else?
   
   The key of an Azure location is treated as percent-encoded and is decoded 
once, by `AzureUri.decodeKey` (fe-filesystem-azure). The HTTPS form is decoded 
twice:
   
   1. `StorageUriUtils.convertAzureToS3Style` rewrites `https://` / `http://` 
locations to `s3://<container>/<key>` using `URI.getPath()`, which already 
percent-decodes the path: `a%2Bb` becomes `a+b`. The `wasb[s]://` / 
`abfs[s]://` branch keeps the raw text, so `a%2Bb` stays encoded there.
   2. `AzureUri.decodeKey` then decodes the key with `java.net.URLDecoder`, 
which follows form encoding and turns `+` into a space: `a+b` becomes `a b`.
   
   A related case follows from (2) alone: a literal, unencoded `+` in a 
`wasb[s]://` / `abfs[s]://` / `https://` path (for example 
`abfss://[email protected]/a+b/1/a.csv`) is also turned into a 
space, although `+` in a URI path is a literal plus sign.
   
   Possible fix:
   
   - In `convertAzureToS3Style`, build the s3-style location from 
`URI.getRawPath()`, so every scheme hands `AzureUri` the same still-encoded key.
   - In `AzureUri.decodeKey`, decode only `%XX` escapes and keep `+` as is 
(e.g. escape `+` as `%2B` before `URLDecoder.decode`), so a path segment such 
as a partition value `+08:00` is preserved.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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