URLWithString fails to fails with bad string

2009-11-24 Thread lorenzo7620
This returns a non-nil value: NSURL * url = [NSURL URLWithString:@"sdsds"]; The docs say this should fail. RFC 1758 looks for the string to begin with a scheme, eg http: I would expect a malforrned string, ie, htt: to work, since URLWithString doesn't distinguish between "htt:" and "http:", b

Re: URLWithString fails to fails with bad string

2009-11-24 Thread Graham Cox
On 25/11/2009, at 5:14 PM, lorenzo7...@gmail.com wrote: > This returns a non-nil value: > NSURL * url = [NSURL URLWithString:@"sdsds"]; > > The docs say this should fail. RFC 1758 looks for the string to begin with a > scheme, eg http: > I would expect a malforrned string, ie, htt: to work, sin

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Kyle Sluder
On Tue, Nov 24, 2009 at 10:14 PM, wrote: > This returns a non-nil value: > NSURL * url = [NSURL URLWithString:@"sdsds"]; > > The docs say this should fail. RFC 1758 looks for the string to begin with a > scheme, eg http: While "sdsds" is indeed a valid relative URL according to RFC 2396, don't l

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Jens Alfke
On Nov 25, 2009, at 8:31 AM, lorenzo7...@gmail.com wrote: > So is there a way to validate a string before passing it to URLWithString? Depends on what you want to do. If you want URLs of a specific scheme, check the -scheme property of the resulting NSURL. That will weed out degenerate cases l

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Jens Alfke
On Nov 25, 2009, at 8:59 AM, lorenzo7...@gmail.com wrote: > Thanks for the reply. I'm looking through the Cocoa API now. I think I might > be able to use NSNetService's -resolveWithTimeout along with NSURL's -scheme > to validate a string. Seems like more work than should be necessary, but oh

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Dave Carrigan
On Nov 25, 2009, at 9:28 AM, lorenzo7...@gmail.com wrote: > I was just looking through the API to see what methods might help me with > this and NSNetService looked like it might work, until I read the class > description. What I'm doing exactly, is downloading batches of web pages via > http.

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Mike Abdullah
You should be able to weed stuff out pretty quickly by: 1) Use +URLWithString: to see if the string can be interpreted as a URL 2) Construct a request with the URL and see what +[NSURLConnection canHandleRequest:] has to say 3) Try to load the URL On 25 Nov 2009, at 17:28, lorenzo7...@gmail.com

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Jens Alfke
On Nov 25, 2009, at 9:34 AM, Dave Carrigan wrote: The only way to determine the validity of a well-formed url is to attempt to retrieve it. The two of you are using different terminology. He's asking how to tell if a URL is well-formed. Lorenzo: If you want to know if you can retrieve a

Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620
On Nov 25, 2009 2:06am, Kyle Sluder wrote: On Tue, Nov 24, 2009 at 10:14 PM, lorenzo7...@gmail.com> wrote: > This returns a non-nil value: > NSURL * url = [NSURL URLWithString:@"sdsds"]; > > The docs say this should fail. RFC 1758 looks for the string to begin with a > scheme, eg

Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620
On Nov 25, 2009 10:36am, Jens Alfke wrote: On Nov 25, 2009, at 8:31 AM, lorenzo7...@gmail.com wrote: > So is there a way to validate a string before passing it to URLWithString? Depends on what you want to do. If you want URLs of a specific scheme, check the -scheme property of the

Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620
On Nov 25, 2009 11:05am, Jens Alfke wrote: On Nov 25, 2009, at 8:59 AM, lorenzo7...@gmail.com wrote: > Thanks for the reply. I'm looking through the Cocoa API now. I think I might be able to use NSNetService's -resolveWithTimeout along with NSURL's -scheme to validate a string. Seems l

Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620
On Nov 25, 2009 11:34am, Dave Carrigan wrote: On Nov 25, 2009, at 9:28 AM, lorenzo7...@gmail.com wrote: > I was just looking through the API to see what methods might help me with this and NSNetService looked like it might work, until I read the class description. What I'm doing exactl