Permalink
Browse files

Increasing data sanitation in XMPPMessageArchivingCoreDataStorage

  • Loading branch information...
1 parent 9c813ae commit 84f0c00a7e53b50e725058e70cfe37454a8ed12a @robbiehanson committed Aug 2, 2012
@@ -60,11 +60,18 @@ - (void)setBareJid:(XMPPJID *)bareJid
- (void)setBareJidStr:(NSString *)bareJidStr
{
+ if ([self.bareJidStr isEqualToString:bareJidStr])
+ {
+ return; // No change
+ }
+
[self willChangeValueForKey:@"bareJid"];
[self willChangeValueForKey:@"bareJidStr"];
- self.primitiveBareJid = [XMPPJID jidWithString:bareJidStr];
- self.primitiveBareJidStr = bareJidStr;
+ XMPPJID *bareJid = [[XMPPJID jidWithString:bareJidStr] bareJID];
+
+ self.primitiveBareJid = bareJid;
+ self.primitiveBareJidStr = [bareJid bare];
[self didChangeValueForKey:@"bareJid"];
[self didChangeValueForKey:@"bareJidStr"];
@@ -98,10 +98,15 @@ - (XMPPJID *)bareJid
- (void)setBareJid:(XMPPJID *)bareJid
{
+ if ([self.bareJid isEqualToJID:bareJid options:XMPPJIDCompareBare])
+ {
+ return; // No change
+ }
+
[self willChangeValueForKey:@"bareJid"];
[self willChangeValueForKey:@"bareJidStr"];
- self.primitiveBareJid = bareJid;
+ self.primitiveBareJid = [bareJid bareJID];
self.primitiveBareJidStr = [bareJid bare];
[self didChangeValueForKey:@"bareJid"];
@@ -110,11 +115,18 @@ - (void)setBareJid:(XMPPJID *)bareJid
- (void)setBareJidStr:(NSString *)bareJidStr
{
+ if ([self.bareJidStr isEqualToString:bareJidStr])
+ {
+ return; // No change
+ }
+
[self willChangeValueForKey:@"bareJid"];
[self willChangeValueForKey:@"bareJidStr"];
- self.primitiveBareJid = [XMPPJID jidWithString:bareJidStr];
- self.primitiveBareJidStr = bareJidStr;
+ XMPPJID *bareJid = [[XMPPJID jidWithString:bareJidStr] bareJID];
+
+ self.primitiveBareJid = bareJid;
+ self.primitiveBareJidStr = [bareJid bare];
[self didChangeValueForKey:@"bareJid"];
[self didChangeValueForKey:@"bareJidStr"];

0 comments on commit 84f0c00

Please sign in to comment.