]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_http_cache: fixed validation of S3 URL
authorChris Rienzo <chris.rienzo@grasshopper.com>
Mon, 10 Feb 2014 13:54:43 +0000 (08:54 -0500)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Mon, 10 Feb 2014 13:55:09 +0000 (08:55 -0500)
src/mod/applications/mod_http_cache/aws.c
src/mod/applications/mod_http_cache/test_aws/main.c

index bea30144db1a0ee58c3600e7d67f3f425572e7b1..4d446d585735fb9183831ef06a56c9a95dc9ae8a 100644 (file)
@@ -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?://\\w[\\w.]{1,61}\\w\\.s3([-\\w]+)?\\.amazonaws\\.com/.*$") == SWITCH_STATUS_SUCCESS;
+       return !zstr(url) && switch_regex_match(url, "^https?://\\w[-\\w.]{1,61}\\w\\.s3([-\\w]+)?\\.amazonaws\\.com/.*$") == SWITCH_STATUS_SUCCESS;
 }
 
 /**
index f9ed1dcfbf9450f947260b225b9c9692cc0b3b01..c29f1364ec96f61c5c4a4c081d154956eee1e4e7 100644 (file)
@@ -107,6 +107,10 @@ static void test_parse_url(void)
        aws_s3_parse_url(strdup("http://bucket.s3.amazonaws.com/voicemails/recording.wav"), &bucket, &object);
        ASSERT_STRING_EQUALS("bucket", bucket);
        ASSERT_STRING_EQUALS("voicemails/recording.wav", object);
+
+       aws_s3_parse_url(strdup("https://my-bucket-with-dash.s3-us-west-2.amazonaws.com/greeting/file/1002/Lumino.mp3"), &bucket, &object);
+       ASSERT_STRING_EQUALS("my-bucket-with-dash", bucket);
+       ASSERT_STRING_EQUALS("greeting/file/1002/Lumino.mp3", object);
 }
 
 /**