Malformed URL string in openURL

2011-06-07 Thread James Merkel
I am sending a URL string to NSWorkspace's  openURL method that has  
the bracket characters ( ) in it. The URL can't be opened by   
NSWorkspace. If I take out the ( ) characters NSWorkspace then opens  
the URL, so I guess NSWorkspace considers the string with ( ) a  
malformed URL.


Note, the ( ) characters are used by Mapquest to label a location. If  
I just enter the URL string with brackets in the browser , it opens  
mapquest ok.


Is there any way around this problem?

Thanks,
Jim Merkel
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Jeffrey Walton
On Tue, Jun 7, 2011 at 7:42 PM, James Merkel jmerk...@mac.com wrote:
 I am sending a URL string to NSWorkspace's  openURL method that has the
 bracket characters ( ) in it. The URL can't be opened by  NSWorkspace. If I
 take out the ( ) characters NSWorkspace then opens the URL, so I guess
 NSWorkspace considers the string with ( ) a malformed URL.

 Note, the ( ) characters are used by Mapquest to label a location. If I just
 enter the URL string with brackets in the browser , it opens mapquest ok.

 Is there any way around this problem?
Forgive the obvious: have you tried an HTML escape - #40; and #41;?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Jeffrey Walton
On Tue, Jun 7, 2011 at 8:03 PM, Jeffrey Walton noloa...@gmail.com wrote:
 On Tue, Jun 7, 2011 at 7:42 PM, James Merkel jmerk...@mac.com wrote:
 I am sending a URL string to NSWorkspace's  openURL method that has the
 bracket characters ( ) in it. The URL can't be opened by  NSWorkspace. If I
 take out the ( ) characters NSWorkspace then opens the URL, so I guess
 NSWorkspace considers the string with ( ) a malformed URL.

 Note, the ( ) characters are used by Mapquest to label a location. If I just
 enter the URL string with brackets in the browser , it opens mapquest ok.

 Is there any way around this problem?
 Forgive the obvious: have you tried an HTML escape - #40; and #41;?
My bad - URL escapes: %28 and %29.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Jens Alfke

On Jun 7, 2011, at 4:42 PM, James Merkel wrote:

 I am sending a URL string to NSWorkspace's  openURL method that has the 
 bracket characters ( ) in it. The URL can't be opened by  NSWorkspace. If I 
 take out the ( ) characters NSWorkspace then opens the URL, so I guess 
 NSWorkspace considers the string with ( ) a malformed URL.

That’s weird, since RFC 1738 explicitly says parentheses are legal and don’t 
need to be escaped:

Thus, only alphanumerics, the special characters $-_.+!*'(),, and
reserved characters used for their reserved purposes may be used
unencoded within a URL.

Could you show us one of these URLs?

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread James Merkel


On Jun 7, 2011, at 5:06 PM, Jeffrey Walton wrote:

On Tue, Jun 7, 2011 at 8:03 PM, Jeffrey Walton noloa...@gmail.com  
wrote:
On Tue, Jun 7, 2011 at 7:42 PM, James Merkel jmerk...@mac.com  
wrote:
I am sending a URL string to NSWorkspace's  openURL method that  
has the
bracket characters ( ) in it. The URL can't be opened by   
NSWorkspace. If I
take out the ( ) characters NSWorkspace then opens the URL, so I  
guess

NSWorkspace considers the string with ( ) a malformed URL.

Note, the ( ) characters are used by Mapquest to label a location.  
If I just
enter the URL string with brackets in the browser , it opens  
mapquest ok.


Is there any way around this problem?

Forgive the obvious: have you tried an HTML escape - #40; and #41;?

My bad - URL escapes: %28 and %29.


I tried %28 and %29 and that didn't work either.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread James Merkel


On Jun 7, 2011, at 5:39 PM, Jens Alfke wrote:



On Jun 7, 2011, at 4:42 PM, James Merkel wrote:

I am sending a URL string to NSWorkspace's  openURL method that has  
the bracket characters ( ) in it. The URL can't be opened by   
NSWorkspace. If I take out the ( ) characters NSWorkspace then  
opens the URL, so I guess NSWorkspace considers the string with ( )  
a malformed URL.


That’s weird, since RFC 1738 explicitly says parentheses are legal  
and don’t need to be escaped:



  Thus, only alphanumerics, the special characters $-_.+!*'(),, and
  reserved characters used for their reserved purposes may be used
  unencoded within a URL.


Could you show us one of these URLs?

—Jens


The following works ok:

NSString * mapquestURLString;

mapquestURLString = [NSString stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916 
];


	if([[NSWorkspace sharedWorkspace] openURL:[NSURL  
URLWithString:mapquestURLString]]);

else NSLog(@Could not open mapquest);

But if I use the following string, I get the error message:

mapquestURLString = [NSString stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test 
 point label)];


I got the examples from

http://www.mapquestapi.com/link-to-mapquest/#parameters

I'm noticing some of the other examples don't  work also.

Jim Merkel___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Jens Alfke

On Jun 7, 2011, at 6:17 PM, James Merkel wrote:

 The following works ok:
 
 NSString * mapquestURLString;
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916;];

(Just FYI, the -stringWithString call is redundant. You can just assign the 
constant directly to the variable.)

 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test 
 point label)”];

It’s not the parens that are illegal, it’s the spaces. Change them to %20 and 
you should be OK.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread James Merkel


On Jun 7, 2011, at 6:20 PM, Jens Alfke wrote:



On Jun 7, 2011, at 6:17 PM, James Merkel wrote:


The following works ok:

NSString * mapquestURLString;

mapquestURLString = [NSString stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916 
];


(Just FYI, the -stringWithString call is redundant. You can just  
assign the constant directly to the variable.)


mapquestURLString = [NSString stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test 
 point label)”];


It’s not the parens that are illegal, it’s the spaces. Change them  
to %20 and you should be OK.


—Jens


Right you are -- thanks.

I was using stringWithString because I actually  was building  up a  
URL string by appending strings.

I simplified the code to show the problem.

Jim Merkel___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Howard Siegel
On Tue, Jun 7, 2011 at 18:20, Jens Alfke j...@mooseyard.com wrote:


 On Jun 7, 2011, at 6:17 PM, James Merkel wrote:

  mapquestURLString = [NSString stringWithString:@
 http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test point label)”];

 It’s not the parens that are illegal, it’s the spaces. Change them to %20
 and you should be OK.


 Or change the spaces to pluses (+).

- h
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Steve Christensen
On Jun 7, 2011, at 6:32 PM, James Merkel wrote:

 On Jun 7, 2011, at 6:20 PM, Jens Alfke wrote:
 
 On Jun 7, 2011, at 6:17 PM, James Merkel wrote:
 
 The following works ok:
 
 NSString * mapquestURLString;
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916;];
 
 (Just FYI, the -stringWithString call is redundant. You can just assign the 
 constant directly to the variable.)
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test 
 point label)”];
 
 It’s not the parens that are illegal, it’s the spaces. Change them to %20 
 and you should be OK.
 
 —Jens
 
 Right you are -- thanks.
 
 I was using stringWithString because I actually  was building  up a URL 
 string by appending strings.
 I simplified the code to show the problem.

Is there some reason you're not using built-in support to properly escape 
strings that are part of URLs?

NSString* mapType = @hybrid;
NSString* location = @39.7452,-104.98916(Test point label);

mapquestURLString = [NSString 
stringWithFormat:@http://mapq.st/?maptype=%@q=%@;,
[mapType 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[location 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread James Merkel


On Jun 7, 2011, at 9:52 PM, Steve Christensen wrote:


stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding


Yeah, I just found that method about an hour ago!

Not related to Cocoa -- but It turns out after playing around with  
this with mapquest and google maps, adding a label can change the view  
that you get (particularly in google maps).
So I probably won't add that. But at least I found out how to get a  
legal URL string in the process.


Thanks,

Jim Merkel
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com