Skip to content

Conversation

IchordeDionysos
Copy link
Contributor

@IchordeDionysos IchordeDionysos commented Jul 10, 2020

Description

Equality checking of references is not user input safe as the internal Pointer check unnormalized paths.

Related Issues

#2928

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • If the pull request affects only one plugin, the PR title starts with the name of the plugin in brackets (e.g. [cloud_firestore])
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • NOT NEEDED: I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • NOT NEEDED: I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@Ehesp
Copy link
Member

Ehesp commented Jul 10, 2020

Thanks for that, really good catch!

@IchordeDionysos
Copy link
Contributor Author

Not sure if I should update the CHANGELOG or version as a version wasn't yet uploaded?

@Ehesp
Copy link
Member

Ehesp commented Jul 10, 2020

Should be ok (cc @Salakar) - we haven't cut a dev release yet and it's not a user facing change so should be good.

@Salakar
Copy link
Member

Salakar commented Jul 10, 2020

Not sure if I should update the CHANGELOG or version as a version wasn't yet uploaded?

Ye as above, no need to worry about those, though if the behaviour was also incorrect on the previous Firestore before the rework then feel free to add it to the existing change log for the rework.

@Salakar Salakar changed the title [cloud_firestore_platform_interface] Fix Firestore pointer path normalization fix(firestore): normalize Firestore pointer path Jul 10, 2020
@IchordeDionysos
Copy link
Contributor Author

IchordeDionysos commented Jul 10, 2020

@Salakar well, tested it on an older version, and it didn't work there either.

So I'll add it to the CHANGELOG. :) I hope I'll do it correctly :D

@IchordeDionysos
Copy link
Contributor Author

Additional note:

With the implementation in the PR calling .path now always returns the path in the same format, which might be breaking for some users.

But I think is more in line with how the native libraries handle it. :)

print(Firestore.instance.collection('test').path);
print(Firestore.instance.collection('/test').path);

final snap = await Firestore.instance.document('/some/doc').get();
final ref = snap.data['referenceToOtherDoc'] as DocumentReference;
print(ref.path);

Printed originally:

test
/test
some/otherDoc

And now prints:

test
test
some/otherDoc

Web implementation:
I've checked how web handles it:

console.log(firebase.firestore().collection('test').path);
console.log(firebase.firestore().collection('/test').path);

prints out:

test
test

So I think we should be fine with the implementation of this PR.

@IchordeDionysos
Copy link
Contributor Author

IchordeDionysos commented Jul 10, 2020

@Salakar After doing some research of the current behavior I think there should definitely be some entry in the CHANGELOG, as this

  1. fixes the current behavior for equality checks and
  2. might be a breaking change for some users if they do something like:
Firestore.instance.collection('/test').path == '/test' // Will now be false, instead of true

Copy link
Member

@Salakar Salakar left a comment

Choose a reason for hiding this comment

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

LGTM

@Salakar Salakar merged commit 2bfa0f6 into firebase:master Jul 10, 2020
@creativecreatorormaybenot creativecreatorormaybenot deleted the fix-firestore-pointer-path-normalization branch July 10, 2020 17:19
@firebase firebase locked and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants