yuseok89 commented on code in PR #77003:
URL: https://github.com/apache/airflow/pull/77003#discussion_r4580794902


##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/s3.py:
##########
@@ -242,15 +242,16 @@ def parse_s3_url(s3url: str) -> tuple[str, str]:
         valid_s3_virtual_hosted_format = 
"https://bucket-name.s3.region-code.amazonaws.com/key-name";
         format = s3url.split("//")
         if re.match(r"s3[na]?:", format[0], re.IGNORECASE):
-            parsed_url = urlsplit(s3url, allow_fragments=False)
-            if not parsed_url.netloc:
+            # Split by hand: urlsplit would treat "?" in an S3 key as the 
start of a query string.
+            # Like urlsplit, drop tabs and newlines (e.g. a trailing newline 
from a templated value).
+            bucket_name, _, key = re.sub(r"[\t\r\n]", "", 
s3url).partition("//")[2].partition("/")

Review Comment:
   Could splitting on the first `//` anywhere in the string cause a regression? 
A URL with a missing slash after the scheme used to fail to parse, but now 
takes the bucket from a later `//` in the path. Would it make sense to split 
only when `://` comes right after the scheme?



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

Reply via email to