Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

emoji/unsafe identifiers and identifier collisions #46

Closed
wants to merge 16 commits into from
Closed

emoji/unsafe identifiers and identifier collisions #46

wants to merge 16 commits into from

Conversation

skibz
Copy link

@skibz skibz commented Jan 25, 2019

as discussed previously:

  • emojis found in chat identifiers are converted to emojitag, and then have their unsafe characters stripped using the existing regex solution

  • identifiers that have already been encountered are given an integer suffix to make them distinct

  • adds test (util_test.go) to assert behaviour is correct

  • adds a dependency (😭) to help with managing emoji

  • add missing empty string test cases

  • add test cases for other types of invalid irc nicknames (eg: $$$)

  • implement an encoding solution for said nicknames

@skibz
Copy link
Author

skibz commented Jan 25, 2019

i just realised now while looking at the diff that i should not have exported ircSafeString because there is already SafeString exported. sorry about that! i will fix this up as soon as possible.

@skibz
Copy link
Author

skibz commented Jan 25, 2019

it also just occurred to me that the tests i've written never assert that a resulting identifier is not an empty string! which is totally missing the point of this whole exercise 😄

i should also have a test case for when an identifier is entirely composed of non-emoji special characters.

what i'm thinking is that if someone has the name $$$ in whatsapp, they'd also end up with an empty string for name. so ultimately we'd have to find a new encoding to use for those sorts of names.

perhaps we could convert those names to a string containing the original identifier's hexadecimal representation, then prefix it with a safe character (like x or something) so that it doesn't look like a phone number.

eg: using the original example name $$$ the encoding i'm proposing would result in the name x242424.

a client can then also decode the name back to $$$ quite easily.

@skibz skibz changed the title emoji identifiers and identifier collisions emoji/unsafe identifiers and identifier collisions Jan 25, 2019
@lieuwex
Copy link
Owner

lieuwex commented Jan 25, 2019

The problem with appending a number at the end of the identifier is is that the order of the chats in memory is arbitrary, so after a restart the identifier<->chat mapping can be completely different, or not, it depends. We should maybe add some ordering to the chat list as well.

About the issue with completely empty chatnames, I'm not sure what to do. I guess hex is a solution, I don't think it happens too often. So everything goes, I guess.

util.go Outdated Show resolved Hide resolved
util.go Outdated Show resolved Hide resolved
util.go Outdated Show resolved Hide resolved
util_test.go Outdated Show resolved Hide resolved
util_test.go Outdated Show resolved Hide resolved
@skibz
Copy link
Author

skibz commented Jan 28, 2019

The problem with appending a number at the end of the identifier is is that the order of the chats in memory is arbitrary, so after a restart the identifier<->chat mapping can be completely different, or not, it depends. We should maybe add some ordering to the chat list as well.

oh man, i hadn't considered this. what sort of ordering do you propose? maybe there's a way we can side-step this problem entirely. is there a data-point provided by whatsapp that could be used to uniquely identify contacts?

@lieuwex
Copy link
Owner

lieuwex commented Jan 28, 2019

is there a data-point provided by whatsapp that could be used to uniquely identify contacts?

IDs, but they aren't user friendly per se, I guess.

@lieuwex
Copy link
Owner

lieuwex commented Jan 28, 2019

Okayyyy, due to some difficulties in how I wanted to fix the problem, I have merged your PR as 6732fee. The tests are missing, I don't really care, but if you do you can rewrite them since the code is a bit changed now :P. Thanks!

@lieuwex lieuwex closed this Jan 28, 2019
@skibz
Copy link
Author

skibz commented Jan 28, 2019

🍾

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants