Skip to content

Commit 3f416bb

Browse files
committed
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...
1 parent a775582 commit 3f416bb

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

GLFileView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- (void)showFile;
3232
- (void)didLoad;
3333
- (NSString *)parseBlame:(NSString *)txt;
34-
+ (NSString *)parseHTML:(NSString *)txt;
34+
+ (NSString *)cleanupHTML:(NSString *)txt;
3535
+ (NSString *)parseDiff:(NSString *)txt;
3636
+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats;
3737
+ (NSString *)getFileName:(NSString *)line;

GLFileView.m

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ - (void) showFile
110110
if(startFile==@"fileview"){
111111
fileTxt=[file textContents:&theError];
112112
if(!theError)
113-
fileTxt=[GLFileView parseHTML:fileTxt];
113+
fileTxt=[GLFileView cleanupHTML:fileTxt];
114114
}else if(startFile==@"blame"){
115115
fileTxt=[file blame:&theError];
116116
if(!theError)
@@ -240,13 +240,16 @@ - (void)closeView
240240
[super closeView];
241241
}
242242

243-
+ (NSString *) parseHTML:(NSString *)txt
243+
+ (NSString *) cleanupHTML:(NSString *)txt
244244
{
245-
txt=[txt stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
246-
txt=[txt stringByReplacingOccurrencesOfString:@"<" withString:@"&lt;"];
247-
txt=[txt stringByReplacingOccurrencesOfString:@">" withString:@"&gt;"];
245+
NSMutableString *newTxt = [NSMutableString stringWithString:txt];
246+
[newTxt replaceOccurrencesOfString:@"&" withString:@"&amp;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
247+
[newTxt replaceOccurrencesOfString:@"<" withString:@"&lt;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
248+
[newTxt replaceOccurrencesOfString:@">" withString:@"&gt;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
249+
[newTxt replaceOccurrencesOfString:@"\"" withString:@"&quot;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
250+
[newTxt replaceOccurrencesOfString:@"'" withString:@"&apos;" options:NSLiteralSearch range:NSMakeRange(0, [newTxt length])];
248251

249-
return txt;
252+
return newTxt;
250253
}
251254

252255
+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats
@@ -296,7 +299,7 @@ + (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)sta
296299

297300
+ (NSString *)parseDiff:(NSString *)txt
298301
{
299-
txt=[self parseHTML:txt];
302+
txt=[self cleanupHTML:txt];
300303

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

505508
- (NSString *) parseBlame:(NSString *)txt
506509
{
507-
txt=[GLFileView parseHTML:txt];
510+
txt=[GLFileView cleanupHTML:txt];
508511

509512
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
510513
NSString *line;

PBWebHistoryController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ - (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges
167167
}
168168
}else{
169169
if (subj) {
170-
[subject appendString:[NSString stringWithFormat:@"%@<br/>",[line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]];
170+
NSString *trimmedLine = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
171+
[subject appendString:[NSString stringWithFormat:@"%@<br/>",[GLFileView cleanupHTML:trimmedLine]]];
171172
}else{
172173
NSArray *comps=[line componentsSeparatedByString:@" "];
173174
if([comps count]==2){

0 commit comments

Comments
 (0)