Skip to content

Commit

Permalink
Fix false group name and avatar updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and alan-signal committed Sep 25, 2020
1 parent 8dbc721 commit dc9370c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
import org.whispersystems.libsignal.util.guava.Optional;

import java.util.Arrays;
import java.util.Objects;

class EditProfileViewModel extends ViewModel {
Expand Down Expand Up @@ -121,9 +122,9 @@ public void submitProfile(Consumer<EditProfileRepository.UploadResult> uploadRes

repository.uploadProfile(profileName,
displayName,
!Objects.equals(oldDisplayName, displayName),
!Objects.equals(StringUtil.stripBidiProtection(oldDisplayName), displayName),
newAvatar,
oldAvatar != newAvatar,
!Arrays.equals(oldAvatar, newAvatar),
uploadResultConsumer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ public static boolean isVisuallyEmpty(char c) {
.toString();
}

public static @Nullable String stripBidiProtection(@Nullable String text) {
if (text == null) return null;

return text.replaceAll("[\\u2068\\u2069\\u202c]", "");
}

/**
* Trims a {@link CharSequence} of starting and trailing whitespace. Behavior matches
* {@link String#trim()} to preserve expectations around results.
Expand Down

0 comments on commit dc9370c

Please sign in to comment.