Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FirebaseStorage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased
- [fixed] Fixed an issue with the List API that prevented listing of locations
that contain the "+" sign.

# 7.0.0
- [changed] The global variable `FIRStorageVersionString` is deleted.
`FirebaseVersion()` or `FIRFirebaseVersion()` should be used instead.
Expand Down
6 changes: 6 additions & 0 deletions FirebaseStorage/Sources/FIRStorageUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ + (NSURLRequest *)defaultRequestForPath:(FIRStoragePath *)path
[queryItems addObject:[NSURLQueryItem queryItemWithName:key value:queryParams[key]]];
}
[components setQueryItems:queryItems];
// NSURLComponents does not encode "+" as "%2B". This is however required by our backend, as
// it treats "+" as a shorthand encoding for spaces. See also
// https://stackoverflow.com/questions/31577188/how-to-encode-into-2b-with-nsurlcomponents
[components setPercentEncodedQuery:[[components percentEncodedQuery]
stringByReplacingOccurrencesOfString:@"+"
withString:@"%2B"]];

NSString *encodedPath = [self encodedURLForPath:path];
[components setPercentEncodedPath:encodedPath];
Expand Down
36 changes: 36 additions & 0 deletions FirebaseStorage/Tests/Unit/FIRStorageListTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,42 @@ - (void)testListWithPageSizeAndPageToken {
[FIRStorageTestHelpers waitForExpectation:self];
}

- (void)testPercentEncodesPlusToken {
XCTestExpectation *expectation = [self expectationWithDescription:@"testPercentEncodesPlusToken"];
NSURL *expectedURL = [NSURL URLWithString:@"https://firebasestorage.googleapis.com/v0/b/bucket/"
@"o?prefix=%2Bfoo/&delimiter=/"];

self.fetcherService.testBlock =
^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you avoid the pragma with an approach like #6693?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting an unused variable warning, and I don't see how the code you linked to doesn't generate the same warning. Is there any trick I need to employ?

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertEqualObjects(fetcher.request.URL, expectedURL); // Implicitly retains self
XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"GET");
#pragma clang diagnostic pop
NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
statusCode:200
HTTPVersion:kHTTPVersion
headerFields:nil];
response(httpResponse, nil, nil);
};

FIRStoragePath *path =
[FIRStoragePath pathFromString:@"https://firebasestorage.googleapis.com/v0/b/bucket/0/+foo"];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
FIRStorageListTask *task = [[FIRStorageListTask alloc]
initWithReference:ref
fetcherService:self.fetcherService
dispatchQueue:self.dispatchQueue
pageSize:nil
previousPageToken:nil
completion:^(FIRStorageListResult *result, NSError *error) {
[expectation fulfill];
}];
[task enqueue];

[FIRStorageTestHelpers waitForExpectation:self];
}

- (void)testListWithResponse {
XCTestExpectation *expectation = [self expectationWithDescription:@"testListWithErrorResponse"];

Expand Down