adium 3183:d60e3dc89642: A couple of AH2 improvements:
commits at adium.im
commits at adium.im
Wed May 5 03:44:18 UTC 2010
details: http://hg.adium.im/adium/rev/d60e3dc89642
revision: 3183:d60e3dc89642
author: Stephen Holt <sholt at adium.im>
date: Tue May 04 20:43:27 2010 -0700
A couple of AH2 improvements:
* Ditch the ignorable tag, reenabel ccTLDs and extend the min URL match length to 5 chars or greater
* LSCopyAllHandlersForURLScheme works better than LSCopyDefaultHandlerForURLScheme.
(We may not have defined a 'default' handler for the scheme yet.)
diffs (73 lines):
diff -r e67d69a74a48 -r d60e3dc89642 Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m
--- a/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m Thu Apr 29 14:36:21 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m Tue May 04 20:43:27 2010 -0700
@@ -279,8 +279,8 @@
AH_URI_VERIFICATION_STATUS validStatus;
NSString *_scanString = nil;
unsigned long schemeLength = 0;
- if(3 < scannedRange.length) _scanString = [m_scanString substringWithRange:scannedRange];
- if((3 < scannedRange.length) && [[self class] isStringValidURI:_scanString usingStrict:m_strictChecking fromIndex:&m_scanLocation withStatus:&validStatus schemeLength:&schemeLength]){
+ if(4 < scannedRange.length) _scanString = [m_scanString substringWithRange:scannedRange];
+ if((4 < scannedRange.length) && [[self class] isStringValidURI:_scanString usingStrict:m_strictChecking fromIndex:&m_scanLocation withStatus:&validStatus schemeLength:&schemeLength]){
AHMarkedHyperlink *markedLink;
BOOL makeLink = TRUE;
//insert typical specifiers if the URL is degenerate
@@ -312,11 +312,11 @@
case AH_URL_TENTATIVE:
{
NSString *scheme = [_scanString substringToIndex:schemeLength];
- NSString *app = (NSString *)LSCopyDefaultHandlerForURLScheme((CFStringRef)scheme);
+ NSArray *apps = (NSArray *)LSCopyAllHandlersForURLScheme((CFStringRef)scheme);
- if(!app)
+ if(!apps.count)
makeLink = FALSE;
- [app release];
+ [apps release];
break;
}
default:
diff -r e67d69a74a48 -r d60e3dc89642 Frameworks/AutoHyperlinks Framework/Source/AHLinkLexer.l
--- a/Frameworks/AutoHyperlinks Framework/Source/AHLinkLexer.l Thu Apr 29 14:36:21 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHLinkLexer.l Tue May 04 20:43:27 2010 -0700
@@ -49,9 +49,7 @@
sTLD (com|edu|gov|int|mil|net|org|biz|info|name|pro)
uTLD (aero|coop|museum|mobi|cat|jobs|travel)
-SLDs (ac|co|gov|ltd|me|mod|net|nhs|nic|org|parliament|plc|police|sch|edu|asn|id)
TLDs ({ccTLD}|{sTLD}|{uTLD}|arpa|local)
-uTLDs (({SLDs}\.{ccTLD})|{sTLD}|{uTLD}|arpa|local)
%{
/*The Unicode standard, version 4.1, table 3-6, says that the highest byte that will occur in a valid UTF-8 sequence is 0xF4.*/
@@ -60,7 +58,7 @@
singleDomain [_[:alnum:]\x80-\xf4-]+
urlPath \/[^[:space:]]*
-urlSpec ({singleDomain}\.)+{uTLDs}(:[0-9]+)?{urlPath}?
+urlSpec ({singleDomain}\.)+{TLDs}(:[0-9]+)?{urlPath}?
urlCSpec {singleDomain}(\.{singleDomain})*(:[0-9]+)?{urlPath}?
ipv4address ([0-9]{1,3}\.){3}([0-9]{1,3})
@@ -75,12 +73,6 @@
userAtDomain [^:@\/[:space:]]+\@{singleDomain}(\.{singleDomain})*
mailSpec {userAtDomain}\.{TLDs}
-%{
-/* Special patterns to ignore */
-%}
-
-ignoreable (b\.sc|m\.in)
-
%option noyywrap nounput 8bit caseless never-interactive reentrant warn prefix="AH"
%x CANONICAL TENTATIVE
@@ -100,8 +92,6 @@
<TENTATIVE>.* {BEGIN INITIAL;
return AH_URL_INVALID;}
-{ignoreable} {return AH_URL_INVALID;}
-
file:\/\/\/.* {return AH_FILE_VALID;}
More information about the commits
mailing list