Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Photo hash comparison is case sensitive #454

Closed
dereck009 opened this issue Oct 22, 2014 · 1 comment
Closed

Bug: Photo hash comparison is case sensitive #454

dereck009 opened this issue Oct 22, 2014 · 1 comment

Comments

@dereck009
Copy link

I have an ejabberd installation which sends photo hashes with letters in all uppercase.

The vCardTempCoreDataStorageObject calculates its own hash from the data with letters in all lowercase.

https://github.com/robbiehanson/XMPPFramework/blob/master/Extensions/XEP-0054/CoreDataStorage/XMPPvCardCoreDataStorageObject.m#L135

[[photoData xmpp_sha1Digest] xmpp_hexStringValue]

Then the vCardAvatarModule uses case sensitive isEqualToString comparison:

https://github.com/robbiehanson/XMPPFramework/blob/master/Extensions/XEP-0153/XMPPvCardAvatarModule.m#L237

This results in the photo always being fetched from the server.

Suggestion: use the caseInsensitiveCompare string method to compare hashes!

@dereck009 dereck009 changed the title Bug: Photo hash comparison is case sensitive (ejabberd) Bug: Photo hash comparison is case sensitive Oct 22, 2014
@dereck009
Copy link
Author

The comparison: https://github.com/robbiehanson/XMPPFramework/blob/master/Extensions/XEP-0153/XMPPvCardAvatarModule.m#L237

...should look like this:

// check the hash
if ([photoHash caseInsensitiveCompare:savedPhotoHash] != NSOrderedSame
    && !([photoHash length] == 0 && [savedPhotoHash length] == 0)) {
    [_xmppvCardTempModule fetchvCardTempForJID:jid ignoreStorage:YES];
}

Note: I also used the savedPhotoHash variable which was defined just above this conditional.

andrewchae pushed a commit to andrewchae/XMPPFramework that referenced this issue Feb 6, 2015
* master: (82 commits)
  Most of the project (excluding the vendor dirs) should now be updated to modern syntax. Resolves issue robbiehanson#449.
  More updates to modern syntax
  Updated gitignore to include .idea dir and began refactoring the codebase to use modern syntax
  Updated XEP-0077 based on conversations at the original PR. No longer using childCount == 0 as validation.
  Fixes allowRosterlessOperation Deadlock
  Universal Roster Item API
  Add support for NSSecureCoding
  Merges robbiehanson#461
  Bulletproofing the file transfer extensions
  Updated log levels
  Added XMPPNamespaces
  Added FileTransfer extension
  Fixes robbiehanson#454
  Fixes robbiehanson#450
  Added documentation
  Added XMPPRegistration to handle XEP-0077
  Updated XMPPMUC to include functionality for discovering rooms and services
  Fixes robbiehanson#395
  Fixes robbiehanson#421
  Fixing many bugs in XMPPStreamManagement.
  ...
@vicky1787 vicky1787 mentioned this issue Dec 23, 2015
davidchiles pushed a commit to davidchiles/XMPPFramework that referenced this issue Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant