Recent

Author Topic: URL Encoding  (Read 6887 times)

RobA

  • New Member
  • *
  • Posts: 14
URL Encoding
« on: December 10, 2021, 10:52:02 pm »
Hi all,

I need to pass some arbitrary text as a query string to a URL that will be opened in the default browser (I'm using Windows) via OpenURL.

Obviously, the query string will need to be URLEncoded - is there a standard function lurking in a unit somewhere for this, or do I need to roll my own? A quick google search didn't come up with anything, but I may have been searching on the wrong terms.

TIA

Rob


RobA

  • New Member
  • *
  • Posts: 14
Re: URL Encoding
« Reply #2 on: December 11, 2021, 12:11:15 am »
Perfect, thank you!

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: URL Encoding
« Reply #3 on: December 11, 2021, 01:25:40 am »

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: URL Encoding
« Reply #4 on: December 11, 2021, 01:52:49 am »
checkout the unit
httpprotocol
it has decode/encode funtionaility as well as other funtions you may find usefull..

just add it to your uses section,
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: URL Encoding
« Reply #5 on: December 11, 2021, 12:10:03 pm »
hi alextp,

just looked at wiki question

should safemask include '('  ')' '$' and  '!' ?
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: URL Encoding
« Reply #6 on: December 11, 2021, 12:16:26 pm »
Maybe, I just copied the ready code from the forum.

Josh

  • Hero Member
  • *****
  • Posts: 1274
Re: URL Encoding
« Reply #7 on: December 11, 2021, 12:41:32 pm »
hi just checking someof my code,
i also whitelist these aswell
',/;#?&:+='

but if my whitelist is correct then, hhtpprotocol unit may need adjusting.

so my list is
A..Z
a..z
0..9
'
*
@
.
_
-
,
/
;
#
?
&
:
+
=
(
)
$
!

<added> I also whitelisted ~ but commented out; can't remember why now though :-\

Does this need verification and checking?
« Last Edit: December 11, 2021, 01:31:24 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

AlexTP

  • Hero Member
  • *****
  • Posts: 2406
    • UVviewsoft
Re: URL Encoding
« Reply #8 on: December 11, 2021, 02:07:21 pm »
If you want to post the FPC issue about it, then yes, it needs verification first. compare it with some C++ libs, e.g.

 

TinyPortal © 2005-2018