[Gambas-user] FromURL() converts + to space

Bruce Steers bsteers4 at gmail.com
Wed Oct 18 22:30:27 CEST 2023


On Wed, 18 Oct 2023, 20:31 Benoît Minisini, <
benoit.minisini at gambas-basic.org> wrote:

> Le 18/10/2023 à 19:09, Bruce Steers a écrit :
> > if i use
> >
> > Print FromURL("AB+12.txt")
> >
> > i get "AB 12.txt"
> >
> > is that by design or a bug?
> >
> > the bug has been discovered when using Drag.Paste("text/uri-list") when
> > using Drop on a control with a filename having a + in the name.
> > it seems Drag.Paste("text/uri-list") seems to use the same FromURL()
> > function.
> >
> > Respects
> > BruceS
> >
>
> Yes, it's my fault, it's buggy.
>
> '+' is a space only in the query part of the URL, not in the path part
> where it must be kept as is.
>
> Maybe FromUrl() could transform '+' in space after it has encountered a
> literal '?'.
>
> Note that "AB+12.txt" is not URL, so there is no reason to send it to
> FromURL().
>
> And there should be no problem with Url(), as '+' is always encoded into
> '%2B'.
>
> Regards,
>
> --
> Benoît Minisini.
>

I agree it should translate '+' only after a '?'

As for the URL and using FromURL() I just wrote that as a simple example as
I noticed the same problem with FromURL() and Drag.Paste("text/uri-list")

Of course a Drag.Paste() of text/uri-list containing the above file would
be more like..
file:///home/user/AB+12.txt

The modification you suggest should fix the issue for drag-n-drop if
Drag.Paste() uses FromURL()

Cheers Ben 😎
Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231018/b3b31363/attachment-0001.htm>


More information about the User mailing list