mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.8 KiB
Matlab
44 lines
1.8 KiB
Matlab
8 years ago
|
//
|
||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
9 years ago
|
|
||
|
#import "OWSScrubbingLogFormatter.h"
|
||
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
|
@implementation OWSScrubbingLogFormatter
|
||
|
|
||
|
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
|
||
|
{
|
||
8 years ago
|
NSString *logString = [super formatLogMessage:logMessage];
|
||
9 years ago
|
NSRegularExpression *phoneRegex =
|
||
|
[NSRegularExpression regularExpressionWithPattern:@"\\+\\d{7,12}(\\d{3})"
|
||
|
options:NSRegularExpressionCaseInsensitive
|
||
|
error:nil];
|
||
|
|
||
8 years ago
|
logString = [phoneRegex stringByReplacingMatchesInString:logString
|
||
|
options:0
|
||
|
range:NSMakeRange(0, [logString length])
|
||
|
withTemplate:@"[ REDACTED_PHONE_NUMBER:xxx$1 ]"];
|
||
|
|
||
|
|
||
|
// We capture only the first two characters of the hex string for logging.
|
||
8 years ago
|
// example log line: "Called someFunction with nsData: <01234567 89abcdef>"
|
||
|
// scrubbed output: "Called someFunction with nsData: [ REDACTED_DATA:01 ]"
|
||
8 years ago
|
NSRegularExpression *dataRegex =
|
||
|
[NSRegularExpression regularExpressionWithPattern:@"<([\\da-f]{2})[\\da-f]{6}( [\\da-f]{8})*>"
|
||
|
options:NSRegularExpressionCaseInsensitive
|
||
|
error:nil];
|
||
|
|
||
|
logString = [dataRegex stringByReplacingMatchesInString:logString
|
||
|
options:0
|
||
|
range:NSMakeRange(0, [logString length])
|
||
|
withTemplate:@"[ REDACTED_DATA:$1... ]"];
|
||
|
|
||
|
return logString;
|
||
9 years ago
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|