New method [NSString+Utilities asSafeJSString]

This commit is contained in:
Francis Lachapelle
2015-06-11 11:44:17 -04:00
parent 5e66e8e299
commit a70ea38572
2 changed files with 12 additions and 4 deletions
+4 -1
View File
@@ -1,6 +1,6 @@
/* NSString+Utilities.h - this file is part of SOGo
*
* Copyright (C) 2006-2014 Inverse inc.
* Copyright (C) 2006-2015 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,6 +46,9 @@
- (NSString *) asCSSIdentifier;
- (NSString *) fromCSSIdentifier;
/* JavaScript safety */
- (NSString *) asSafeJSString;
/* SQL safety */
- (NSString *) asSafeSQLString;
+8 -3
View File
@@ -1,6 +1,6 @@
/* NSString+Utilities.m - this file is part of SOGo
*
* Copyright (C) 2006-2014 Inverse inc.
* Copyright (C) 2006-2015 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -257,7 +257,7 @@ static int cssEscapingCount;
return selfCopy;
}
- (NSString *) doubleQuotedString
- (NSString *) asSafeJSString
{
NSMutableString *representation;
@@ -270,7 +270,12 @@ static int cssEscapingCount;
[representation replaceString: @"\r" withString: @"\\r"];
[representation replaceString: @"\t" withString: @"\\t"];
return [NSString stringWithFormat: @"\"%@\"", representation];
return representation;
}
- (NSString *) doubleQuotedString
{
return [NSString stringWithFormat: @"\"%@\"", [self asSafeJSString]];
}
//