mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-23 10:54:17 +00:00
New method [NSString+Utilities asSafeJSString]
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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]];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user