From ae7371e7c577599174db937aa555e1ca20167551 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Fri, 3 Jan 2014 16:21:29 -0500 Subject: [PATCH] mod_http_cache: allow underscore in amazon s3 hostname --- src/mod/applications/mod_http_cache/aws.c | 2 +- src/mod/applications/mod_http_cache/test_aws/main.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_http_cache/aws.c b/src/mod/applications/mod_http_cache/aws.c index 17d6a233ab..cb6db5cb58 100644 --- a/src/mod/applications/mod_http_cache/aws.c +++ b/src/mod/applications/mod_http_cache/aws.c @@ -44,7 +44,7 @@ int aws_s3_is_s3_url(const char *url) { /* AWS bucket naming rules are complex... this match only supports virtual hosting of buckets */ - return !zstr(url) && switch_regex_match(url, "^https?://[a-z0-9][-a-z0-9.]{1,61}[a-z0-9]\\.s3\\.amazonaws\\.com/.*$") == SWITCH_STATUS_SUCCESS; + return !zstr(url) && switch_regex_match(url, "^https?://[a-z0-9_][-a-z0-9._]{1,61}[a-z0-9_]\\.s3\\.amazonaws\\.com/.*$") == SWITCH_STATUS_SUCCESS; } /** diff --git a/src/mod/applications/mod_http_cache/test_aws/main.c b/src/mod/applications/mod_http_cache/test_aws/main.c index 8610127bbe..6c361ca8f1 100644 --- a/src/mod/applications/mod_http_cache/test_aws/main.c +++ b/src/mod/applications/mod_http_cache/test_aws/main.c @@ -48,6 +48,7 @@ static void test_check_url(void) ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3.amazonaws.com/object")); ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3.amazonaws.com/recordings/1240fwjf8we.mp3")); ASSERT_TRUE(aws_s3_is_s3_url("https://bucket.s3.amazonaws.com/en/us/8000/1232345.mp3")); + ASSERT_TRUE(aws_s3_is_s3_url("https://bucket_with_underscore.s3.amazonaws.com/en/us/8000/1232345.mp3")); ASSERT_FALSE(aws_s3_is_s3_url("bucket.s3.amazonaws.com/object.ext")); ASSERT_FALSE(aws_s3_is_s3_url("https://s3.amazonaws.com/bucket/object")); ASSERT_FALSE(aws_s3_is_s3_url("http://s3.amazonaws.com/bucket/object"));