Skip to content

Commit 9495430

Browse files
committed
Fix b2 for path and virtual host styles
1 parent 0b2493f commit 9495430

File tree

1 file changed

+18
-1
lines changed
  • network/cloud_sync

1 file changed

+18
-1
lines changed

network/cloud_sync/s3.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,27 @@ static bool s3_parse_url(const char *url, char *bucket, char *region,
302302
else if (strstr(host, ".backblazeb2.com"))
303303
{
304304
const char *s3pos = strstr(host, ".s3.");
305+
bool b2_path_style_host = false;
305306

306307
RARCH_LOG(S3_PFX "Detected Backblaze B2 format\n");
307308

308-
if (s3pos)
309+
/* Backblaze B2 path-style host: s3.<region>.backblazeb2.com/<bucket>/... */
310+
if (string_starts_with_case_insensitive(host, "s3."))
311+
{
312+
const char *region_start = host + 3; /* skip "s3." */
313+
second_dot = strchr(region_start, '.');
314+
if (second_dot)
315+
{
316+
size_t region_len = second_dot - region_start;
317+
if (region_len > 0 && region_len < NAME_MAX_LENGTH)
318+
{
319+
strlcpy(region, region_start, region_len + 1);
320+
b2_path_style_host = true;
321+
}
322+
}
323+
}
324+
325+
if (s3pos && !b2_path_style_host)
309326
{
310327
RARCH_LOG(S3_PFX "Backblaze B2 style: virtual-hosted\n");
311328
size_t bucket_len = s3pos - host;

0 commit comments

Comments
 (0)