From 3f416bb8e72dacedd680ef122ba232ae82a2402d Mon Sep 17 00:00:00 2001 From: Romain Muller Date: Sat, 30 Apr 2011 13:03:15 -0700 Subject: [PATCH] Tidy up the commit message to ensure it won't break the diff view. Renamed the GLFileView's +parseHTML into something more meaningful regarding what it actually does. Also, the method might need to be moved to somewhere else... --- GLFileView.h | 2 +- GLFileView.m | 19 +++++++++++-------- PBWebHistoryController.m | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/GLFileView.h b/GLFileView.h index 8084ddc..8cf1d5c 100644 --- a/GLFileView.h +++ b/GLFileView.h @@ -31,7 +31,7 @@ - (void)showFile; - (void)didLoad; - (NSString *)parseBlame:(NSString *)txt; -+ (NSString *)parseHTML:(NSString *)txt; ++ (NSString *)cleanupHTML:(NSString *)txt; + (NSString *)parseDiff:(NSString *)txt; + (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats; + (NSString *)getFileName:(NSString *)line; diff --git a/GLFileView.m b/GLFileView.m index f6d68c6..4e4a27c 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -110,7 +110,7 @@ if(startFile==@"fileview"){ fileTxt=[file textContents:&theError]; if(!theError) - fileTxt=[GLFileView parseHTML:fileTxt]; + fileTxt=[GLFileView cleanupHTML:fileTxt]; }else if(startFile==@"blame"){ fileTxt=[file blame:&theError]; if(!theError) @@ -240,13 +240,16 @@ [super closeView]; } -+ (NSString *) parseHTML:(NSString *)txt ++ (NSString *) cleanupHTML:(NSString *)txt { - txt=[txt stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; - txt=[txt stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; - txt=[txt stringByReplacingOccurrencesOfString:@">" withString:@">"]; + NSMutableString *newTxt = [NSMutableString stringWithString:txt]; + [newTxt replaceOccurrencesOfString:@"&" withString:@"&" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; + [newTxt replaceOccurrencesOfString:@"<" withString:@"<" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; + [newTxt replaceOccurrencesOfString:@">" withString:@">" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; + [newTxt replaceOccurrencesOfString:@"\"" withString:@""" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; + [newTxt replaceOccurrencesOfString:@"'" withString:@"'" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])]; - return txt; + return newTxt; } + (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats @@ -296,7 +299,7 @@ + (NSString *)parseDiff:(NSString *)txt { - txt=[self parseHTML:txt]; + txt=[self cleanupHTML:txt]; NSMutableString *res=[NSMutableString string]; NSScanner *scan=[NSScanner scannerWithString:txt]; @@ -504,7 +507,7 @@ - (NSString *) parseBlame:(NSString *)txt { - txt=[GLFileView parseHTML:txt]; + txt=[GLFileView cleanupHTML:txt]; NSArray *lines = [txt componentsSeparatedByString:@"\n"]; NSString *line; diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index b422132..7dd0898 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -167,7 +167,8 @@ } }else{ if (subj) { - [subject appendString:[NSString stringWithFormat:@"%@
",[line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]]; + NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + [subject appendString:[NSString stringWithFormat:@"%@
",[GLFileView cleanupHTML:trimmedLine]]]; }else{ NSArray *comps=[line componentsSeparatedByString:@" "]; if([comps count]==2){