Skip to content

Commit

Permalink
Tidy up the commit message to ensure it won't break the diff view.
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
RomainMuller committed Apr 30, 2011
1 parent a775582 commit 3f416bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GLFileView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 11 additions & 8 deletions GLFileView.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (void) showFile
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)
Expand Down Expand Up @@ -240,13 +240,16 @@ - (void)closeView
[super closeView];
}

+ (NSString *) parseHTML:(NSString *)txt
+ (NSString *) cleanupHTML:(NSString *)txt
{
txt=[txt stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
txt=[txt stringByReplacingOccurrencesOfString:@"<" withString:@"&lt;"];
txt=[txt stringByReplacingOccurrencesOfString:@">" withString:@"&gt;"];
NSMutableString *newTxt = [NSMutableString stringWithString:txt];
[newTxt replaceOccurrencesOfString:@"&" withString:@"&amp;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
[newTxt replaceOccurrencesOfString:@"<" withString:@"&lt;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
[newTxt replaceOccurrencesOfString:@">" withString:@"&gt;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
[newTxt replaceOccurrencesOfString:@"\"" withString:@"&quot;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
[newTxt replaceOccurrencesOfString:@"'" withString:@"&apos;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];

return txt;
return newTxt;
}

+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats
Expand Down Expand Up @@ -296,7 +299,7 @@ + (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)sta

+ (NSString *)parseDiff:(NSString *)txt
{
txt=[self parseHTML:txt];
txt=[self cleanupHTML:txt];

NSMutableString *res=[NSMutableString string];
NSScanner *scan=[NSScanner scannerWithString:txt];
Expand Down Expand Up @@ -504,7 +507,7 @@ +(BOOL)isStartBlock:(NSString *)line

- (NSString *) parseBlame:(NSString *)txt
{
txt=[GLFileView parseHTML:txt];
txt=[GLFileView cleanupHTML:txt];

NSArray *lines = [txt componentsSeparatedByString:@"\n"];
NSString *line;
Expand Down
3 changes: 2 additions & 1 deletion PBWebHistoryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ - (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges
}
}else{
if (subj) {
[subject appendString:[NSString stringWithFormat:@"%@<br/>",[line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]];
NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[subject appendString:[NSString stringWithFormat:@"%@<br/>",[GLFileView cleanupHTML:trimmedLine]]];
}else{
NSArray *comps=[line componentsSeparatedByString:@" "];
if([comps count]==2){
Expand Down

0 comments on commit 3f416bb

Please sign in to comment.