Skip to content

Commit

Permalink
Encode IDN URLs, closes #106
Browse files Browse the repository at this point in the history
  • Loading branch information
c99koder committed Sep 30, 2013
1 parent 4588000 commit bc49a69
Show file tree
Hide file tree
Showing 5 changed files with 444 additions and 2 deletions.
6 changes: 6 additions & 0 deletions IRCCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
228A05DE16D3E40F0029769C /* LoginSplashViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 228A05DC16D3E40E0029769C /* LoginSplashViewController.m */; };
228A05DF16D3E40F0029769C /* LoginSplashViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 228A05DD16D3E40F0029769C /* LoginSplashViewController_iPhone.xib */; };
228EFBC8177B4F7300B83A4C /* DisplayOptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 228EFBC7177B4F7300B83A4C /* DisplayOptionsViewController.m */; };
2293AF0117F9CCD10022BD06 /* NSURL+IDN.m in Sources */ = {isa = PBXBuildFile; fileRef = 2293AEFF17F9CCD10022BD06 /* NSURL+IDN.m */; };
22A19C60178FCCAC00772C60 /* UINavigationController+iPadSux.m in Sources */ = {isa = PBXBuildFile; fileRef = 22A19C5F178FCCAB00772C60 /* UINavigationController+iPadSux.m */; };
22A1D0271778A86900F8A89C /* WhoisViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22A1D0261778A86900F8A89C /* WhoisViewController.m */; };
22A35F26178A317100529CDA /* WhoListTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22A35F25178A317100529CDA /* WhoListTableViewController.m */; };
Expand Down Expand Up @@ -281,6 +282,8 @@
228A05DD16D3E40F0029769C /* LoginSplashViewController_iPhone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LoginSplashViewController_iPhone.xib; path = Classes/LoginSplashViewController_iPhone.xib; sourceTree = "<group>"; };
228EFBC6177B4F6000B83A4C /* DisplayOptionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayOptionsViewController.h; sourceTree = "<group>"; };
228EFBC7177B4F7300B83A4C /* DisplayOptionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DisplayOptionsViewController.m; sourceTree = "<group>"; };
2293AEFF17F9CCD10022BD06 /* NSURL+IDN.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSURL+IDN.m"; path = "NSURL+IDN/NSURL+IDN.m"; sourceTree = SOURCE_ROOT; };
2293AF0017F9CCD10022BD06 /* NSURL+IDN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSURL+IDN.h"; path = "NSURL+IDN/NSURL+IDN.h"; sourceTree = SOURCE_ROOT; };
22A19C5E178FCCAB00772C60 /* UINavigationController+iPadSux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+iPadSux.h"; sourceTree = "<group>"; };
22A19C5F178FCCAB00772C60 /* UINavigationController+iPadSux.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+iPadSux.m"; sourceTree = "<group>"; };
22A1D0251778A86900F8A89C /* WhoisViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WhoisViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -487,6 +490,8 @@
228A057616D3DABA0029769C /* Supporting Files */ = {
isa = PBXGroup;
children = (
2293AEFF17F9CCD10022BD06 /* NSURL+IDN.m */,
2293AF0017F9CCD10022BD06 /* NSURL+IDN.h */,
225017411783434800066E71 /* ARChromeActivity */,
22F5C4BB1791EFCD005E09A9 /* config.h */,
22B15CF617301BAE0075EBA7 /* ECSlidingViewController */,
Expand Down Expand Up @@ -868,6 +873,7 @@
22B4287E16D831A800498507 /* WebSocketMessage.m in Sources */,
22B4288616D846BF00498507 /* IRCCloudJSONObject.m in Sources */,
2236F5FA16DA765C007BE535 /* ServersDataSource.m in Sources */,
2293AF0117F9CCD10022BD06 /* NSURL+IDN.m in Sources */,
2236F5FE16DA8928007BE535 /* BuffersDataSource.m in Sources */,
2236F60216DBC021007BE535 /* ChannelsDataSource.m in Sources */,
2236F60616DBCA85007BE535 /* BuffersTableView.m in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion IRCCloud/Classes/ColorFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "TTTAttributedLabel.h"
#import "UIColor+IRCCloud.h"
#import "NetworkConnection.h"
#import "NSURL+IDN.h"

@implementation ColorFormatter

Expand Down Expand Up @@ -443,7 +444,7 @@ +(NSAttributedString *)format:(NSString *)input defaultColor:(UIColor *)color mo
}
}
if(!overlap) {
NSString *url = [[output string] substringWithRange:result.range];
NSString *url = [NSURL IDNEncodedURL:[[output string] substringWithRange:result.range]];
if([url rangeOfString:@"://"].location == NSNotFound)
url = [NSString stringWithFormat:@"http://%@", url];
[matches addObject:[NSTextCheckingResult linkCheckingResultWithRange:result.range URL:[NSURL URLWithString:url]]];
Expand Down
14 changes: 13 additions & 1 deletion IRCCloud/Resources/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,16 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.

NSURL+IDN.m

Created by Jorge Bernal on 4/8/11.
Adapted from OmniNetworking framework

Copyright 1997-2005 Omni Development, Inc. All rights reserved.

This software may only be used and reproduced according to the
terms in the file OmniSourceLicense.html, which should be
distributed with this project and can also be found at
<http://www.omnigroup.com/developer/sourcecode/sourcelicense/>
21 changes: 21 additions & 0 deletions NSURL+IDN/NSURL+IDN.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// NSURL+IDN.h
//
// Created by Jorge Bernal on 4/8/11.
// Adapted from OmniNetworking framework
//
// Copyright 1997-2005 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
// distributed with this project and can also be found at
// <http://www.omnigroup.com/developer/sourcecode/sourcelicense/>.

#import <Foundation/Foundation.h>

@interface NSURL (IDN)
+ (NSString *)IDNEncodedHostname:(NSString *)aHostname;
+ (NSString *)IDNDecodedHostname:(NSString *)anIDNHostname;
+ (NSString *)IDNEncodedURL:(NSString *)aURL;
+ (NSString *)IDNDecodedURL:(NSString *)anIDNURL;
@end
Loading

0 comments on commit bc49a69

Please sign in to comment.