Skip to content

Fix #16973 v.2 - url_encode() url_decode() added to [webtools]

Samuel GOUGEON requested to merge sgougeon/scilab:MR363_url_encode_decode_2 into main

This MR supersedes !293 (merged)

Documentation: https://gitlab.com/scilab/scilab/uploads/2493784e7303945d95d4e12c8796d7fd/url_encode_decode_v2.pdf

Proposed syntaxes:

encoded = url_encode(Strings)
encoded = url_encode(Strings, encMode)
encoded = url_encode(Strings, encMode, encResUnres)
encoded = url_encode(Strings, nonEncodedChars)

decoded = url_decode(Strings)
decoded = url_decode(Strings, "+is+")

with

encMode = "RFC1738" | "RFC2396" | "RFC3986" | "RFC3986+" = "PHP"
          Default = "PHP"
          "RFC3886" = PHP raw

encResUnres = [bool bool]
  encResUnres(1) = %T  encodes reserved characters
  encResUnres(2) = %T  encodes unreserved characters

nonEncodedChars : custom list of characters to not encode, as a string.

"+is+": prevents decoding + into space when it was not in the encoding mode.

Discussion about the naming: Please see other propositions and comment #16973 (closed)

Discussion about decoding requirement:
Basic checkings are done on encoded strings before decoding them. A warning is displayed if

  • any white space is detected
  • any extended character is detected
  • any spurious %## code is detected
Edited by Samuel GOUGEON

Merge request reports