From 823f57deca76a40d148ee967b1bfdc9eb46f1539 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 5 Apr 2012 18:50:05 +0000 Subject: [PATCH] Monotone-Parent: 858274c7be3ad2a6383c2f85c8ad10907bb43292 Monotone-Revision: 2718d596001d2e9358dcce09a959434c8f775f9f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-04-05T18:50:05 --- ChangeLog | 6 ++++++ SoObjects/SOGo/NSString+Utilities.m | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e37e82dbb..c89c74569 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-04-05 Wolfgang Sourdeau + + * SoObjects/SOGo/NSString+Utilities.m (-objectFromJSONString): + added a work-around for JSON strings that were escaped one too + many time, in previous versions of sope-gdl1-xxx. + 2012-04-04 Jean Raby * Added a new tool: 'sogo-tool expire-sessions' diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 0d01f9970..55838a2dc 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -501,6 +501,7 @@ static int cssEscapingCount; SBJsonParser *parser; NSObject *object; NSError *error; + NSString *unescaped; object = nil; @@ -513,9 +514,19 @@ static int cssEscapingCount; error: &error]; if (error) { - [self errorWithFormat: @"json parser: %@", error]; - [self errorWithFormat: @"original string is: %@", self]; - object = nil; + [self errorWithFormat: @"json parser: %@," + @" attempting once more after unescaping...", error]; + unescaped = [self stringByReplacingString: @"\\\\" + withString: @"\\"]; + object = [parser objectWithString: unescaped + error: &error]; + if (error) + { + [self errorWithFormat: @"total failure. Original string is: %@", self]; + object = nil; + } + else + [self logWithFormat: @"initial object deserialized successfully!"]; } }