Skip to content

Does 'sanitizing' url in FUtilities parseUrl: accidentally corrupt host? #8874

Closed
@mortenbekditlevsen

Description

@mortenbekditlevsen

Regarding FirebaseDatabase.

In the referenced line:

[url stringByReplacingOccurrencesOfString:originalPathString

it appears as if the host may be corrupted in case the path is a substring of the host.

For instance:

- (void)testUrlParsedWithPathPartOfHost {
  FParsedUrl *parsedUrl = [FUtilities parseUrl:@"https://sample.firebaseio.com/a"];
  XCTAssertEqualObjects(parsedUrl.repoInfo.host, @"sample.firebaseio.com");
  XCTAssertEqualObjects(parsedUrl.repoInfo.namespace, @"sample");
  XCTAssertTrue(parsedUrl.repoInfo.secure);
  XCTAssertEqualObjects(parsedUrl.path, [FPath pathWithString:@"a"]);
}

Since 'a' is part of 'sample', it will replace it with 'smple'.
This could be an issue in the API: FIRDatabaseReference referenceFromURL: that parses a user-supplied URL.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions