| OLD | NEW |
| (Empty) | |
| 1 /* ***** BEGIN LICENSE BLOCK ***** |
| 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 3 * |
| 4 * The contents of this file are subject to the Mozilla Public License Version |
| 5 * 1.1 (the "License"); you may not use this file except in compliance with |
| 6 * the License. You may obtain a copy of the License at |
| 7 * http://www.mozilla.org/MPL/ |
| 8 * |
| 9 * Software distributed under the License is distributed on an "AS IS" basis, |
| 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 11 * for the specific language governing rights and limitations under the |
| 12 * License. |
| 13 * |
| 14 * The Original Code is Chimera code. |
| 15 * |
| 16 * The Initial Developer of the Original Code is |
| 17 * Netscape Communications Corporation. |
| 18 * Portions created by the Initial Developer are Copyright (C) 2002 |
| 19 * the Initial Developer. All Rights Reserved. |
| 20 * |
| 21 * Contributor(s): |
| 22 * Simon Fraser <sfraser@netscape.com> |
| 23 * |
| 24 * Alternatively, the contents of this file may be used under the terms of |
| 25 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 27 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 28 * of those above. If you wish to allow use of your version of this file only |
| 29 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 30 * use your version of this file under the terms of the MPL, indicate your |
| 31 * decision by deleting the provisions above and replace them with the notice |
| 32 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 33 * the provisions above, a recipient may use your version of this file under |
| 34 * the terms of any one of the MPL, the GPL or the LGPL. |
| 35 * |
| 36 * ***** END LICENSE BLOCK ***** */ |
| 37 |
| 38 #import <Foundation/Foundation.h> |
| 39 |
| 40 typedef enum |
| 41 { |
| 42 kTruncateAtStart, |
| 43 kTruncateAtMiddle, |
| 44 kTruncateAtEnd |
| 45 } ETruncationType; |
| 46 |
| 47 |
| 48 // a category to extend NSString |
| 49 @interface NSString (ChimeraStringUtils) |
| 50 |
| 51 + (id)ellipsisString; |
| 52 + (NSString*)stringWithUUID; |
| 53 |
| 54 - (BOOL)isEqualToStringIgnoringCase:(NSString*)inString; |
| 55 - (BOOL)hasCaseInsensitivePrefix:(NSString*)inString; |
| 56 |
| 57 // Some URIs can contain spaces and still work, even though they aren't strictly
valid |
| 58 // per RFC2396. This method allows us to account for those URIs. |
| 59 - (BOOL)isLooselyValidatedURI; |
| 60 |
| 61 // Utility method to identify URIs that can be run in the context of the current
page. |
| 62 // These URIs could be used as attack vectors via AppleScript, for example. |
| 63 - (BOOL)isPotentiallyDangerousURI; |
| 64 |
| 65 // Utility method to ensure validity of URI strings. NSURL is used to validate |
| 66 // most of them, but the NSURL test may fail for |javascript:| and |data:| URIs |
| 67 // because they often contain invalid (per RFC2396) characters such as spaces. |
| 68 - (BOOL)isValidURI; |
| 69 |
| 70 - (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet; |
| 71 - (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet wit
hString:(NSString*)string; |
| 72 - (NSString *)stringByTruncatingTo:(unsigned int)maxCharacters at:(ETruncationTy
pe)truncationType; |
| 73 - (NSString *)stringByTruncatingToWidth:(float)inWidth at:(ETruncationType)trunc
ationType withAttributes:(NSDictionary *)attributes; |
| 74 - (NSString *)stringByTrimmingWhitespace; |
| 75 - (NSString *)stringByRemovingAmpEscapes; |
| 76 - (NSString *)stringByAddingAmpEscapes; |
| 77 |
| 78 @end |
| 79 |
| 80 @interface NSMutableString (ChimeraMutableStringUtils) |
| 81 |
| 82 - (void)truncateTo:(unsigned)maxCharacters at:(ETruncationType)truncationType; |
| 83 - (void)truncateToWidth:(float)maxWidth at:(ETruncationType)truncationType withA
ttributes:(NSDictionary *)attributes; |
| 84 |
| 85 @end |
| 86 |
| 87 @interface NSString (ChimeraFilePathStringUtils) |
| 88 |
| 89 - (NSString*)volumeNamePathComponent; |
| 90 - (NSString*)displayNameOfLastPathComponent; |
| 91 |
| 92 @end |
| 93 |
| 94 @interface NSString (CaminoURLStringUtils) |
| 95 |
| 96 // Returns true if the string represents a "blank" URL ("" or "about:blank") |
| 97 - (BOOL)isBlankURL; |
| 98 // Returns a URI that looks good in a location field |
| 99 - (NSString *)unescapedURI; |
| 100 |
| 101 @end |
| OLD | NEW |