Esempio n. 1
0
 CF::String URL::GetResourceSpecifier( void )
 {
     CF::String  str;
     CFStringRef cfStr;
     
     if( this->_cfObject == NULL )
     {
         return str;
     }
     
     cfStr = CFURLCopyResourceSpecifier( this->_cfObject );
     
     if( cfStr != NULL )
     {
         str = cfStr;
         
         CFRelease( cfStr );
     }
     
     return str;
 }
OSStatus SecureDownloadCopyTicketLocation (CFURLRef url, CFURLRef *ticketLocation)
{
	API_BEGIN
		Required (ticketLocation);
		Required (url);
		
		// copy the resource specifier
		CFStringRef resourceSpecifier = CFURLCopyResourceSpecifier (url);
		if (resourceSpecifier == NULL)
		{
			CFError::throwMe ();
		}

		// make a new URL from the resource specifier
		*ticketLocation = CFURLCreateWithString (NULL, resourceSpecifier, NULL);
		if (*ticketLocation == NULL)
		{
			CFError::throwMe ();
		}
		
		// check the scheme to make sure that it isn't a file url
		CFStringRef scheme = CFURLCopyScheme (*ticketLocation);
		if (scheme != NULL)
		{
			CFComparisonResult equal = CFStringCompare (scheme, CFSTR("file"), kCFCompareCaseInsensitive);
			CFRelease (scheme);
			
			if (equal == kCFCompareEqualTo)
			{
				CFRelease (*ticketLocation);
				*ticketLocation = NULL;
				MacOSError::throwMe (errSecureDownloadInvalidDownload);
			}
		}
		
		CFRelease (resourceSpecifier);
	API_END
}
Esempio n. 3
0
string URL::resourceSpec() const
{
    return mkstr(CFURLCopyResourceSpecifier(ref));
}