0

i'm writing custom URI scheme, following this article:

https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

my handler looks like this: myScheme://firstItem/SecondItem

the thing is, after the first slash, if i write the "#" with spaces, all spaces are removed.

example:

myScheme://first/second #third

is interpreted as:

myScheme://first/second#third

in my application.

in addition, if it's the first parameter before the slash, a slash is added:

myScheme://first #second

is interpreted as:

myScheme://first /#second

in my application.

Can anyone can explain this behavior?

== EDIT ==

mailto: protocol is the only one who is implemented in similar way, and is working well. onenote, winamp, etc... can't handle those cases.

anyone knows why?

ArielB
  • 1,184
  • 2
  • 11
  • 36

1 Answers1

0

Usually you use percent-encoded spaces, e.g,.

The page Registering an Application to a URI Scheme lists more than one problem with spaces in a URI:

By adding the above settings to the registry, navigating to URIs such as alert:Hello%20World would cause an attempt to launch alert.exe with the complete URI on the command line. Internet Explorer percent-decodes the URI, but the Windows Run... command does not. If a URI contains percent-encoded spaces, it may be split across more than one argument on the command line.

The "split" corresponds to your second part of the question. But later, it comments

When ShellExecute executes the pluggable protocol handler with a stringon the command line, any non-encoded spaces, quotes, and backslashes in the URI will be interpreted as part of the command line. This means that if you use C/C++'s argc and argv to determine the arguments passed to your application, the string may be broken across multiple parameters. To mitigate this issue:

The last part is the recommendation:

Avoid spaces, quotes, or backslashes in your URI

because one part of the system will rely upon percent-encoding while the other is broken by it.

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • i dont mind if the string will be broken into several parameters, i can't tell the end user to encode the special characters. i saw that mailto: doesn't have this issue, nor custom developed protocol handler. isn't there any way that my application will just receive what i've sent? – ArielB Nov 05 '15 at 14:59
  • Apparently not: the applications get a filtered/translated version of what you send. – Thomas Dickey Nov 05 '15 at 15:00
  • So i wonder how mailto overcame this problem.. as it seems they don't have this issue (the sender receives the exact string that is sent) – ArielB Nov 05 '15 at 15:15