mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-06-01 00:02:39 +00:00
global-functions: deprecate $UrlEncode
This commit is contained in:
parent
7fe2785887
commit
d637104a9d
2 changed files with 29 additions and 28 deletions
|
|
@ -7,3 +7,32 @@
|
|||
#
|
||||
# deprecated global functions
|
||||
# https://rsc.eworm.de/
|
||||
|
||||
:global UrlEncode;
|
||||
|
||||
# url encoding
|
||||
:set UrlEncode do={
|
||||
:local Input [ :tostr $1 ];
|
||||
|
||||
:if ([ :len $Input ] = 0) do={
|
||||
:return "";
|
||||
}
|
||||
|
||||
:local Return "";
|
||||
:local Chars ("\n\r !\"#\$%&'()*+,:;<=>?@[\\]^`{|}~");
|
||||
:local Subs { "%0A"; "%0D"; "%20"; "%21"; "%22"; "%23"; "%24"; "%25"; "%26"; "%27";
|
||||
"%28"; "%29"; "%2A"; "%2B"; "%2C"; "%3A"; "%3B"; "%3C"; "%3D"; "%3E"; "%3F";
|
||||
"%40"; "%5B"; "%5C"; "%5D"; "%5E"; "%60"; "%7B"; "%7C"; "%7D"; "%7E" };
|
||||
|
||||
:for I from=0 to=([ :len $Input ] - 1) do={
|
||||
:local Char [ :pick $Input $I ];
|
||||
:local Replace [ :find $Chars $Char ];
|
||||
|
||||
:if ([ :typeof $Replace ] = "num") do={
|
||||
:set Char ($Subs->$Replace);
|
||||
}
|
||||
:set Return ($Return . $Char);
|
||||
}
|
||||
|
||||
:return $Return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@
|
|||
:global SymbolByUnicodeName;
|
||||
:global SymbolForNotification;
|
||||
:global Unix2Dos;
|
||||
:global UrlEncode;
|
||||
:global ValidateSyntax;
|
||||
:global VersionToNum;
|
||||
:global WaitDefaultRouteReachable;
|
||||
|
|
@ -1795,33 +1794,6 @@
|
|||
:return [ :tocrlf [ :tostr $1 ] ];
|
||||
}
|
||||
|
||||
# url encoding
|
||||
:set UrlEncode do={
|
||||
:local Input [ :tostr $1 ];
|
||||
|
||||
:if ([ :len $Input ] = 0) do={
|
||||
:return "";
|
||||
}
|
||||
|
||||
:local Return "";
|
||||
:local Chars ("\n\r !\"#\$%&'()*+,:;<=>?@[\\]^`{|}~");
|
||||
:local Subs { "%0A"; "%0D"; "%20"; "%21"; "%22"; "%23"; "%24"; "%25"; "%26"; "%27";
|
||||
"%28"; "%29"; "%2A"; "%2B"; "%2C"; "%3A"; "%3B"; "%3C"; "%3D"; "%3E"; "%3F";
|
||||
"%40"; "%5B"; "%5C"; "%5D"; "%5E"; "%60"; "%7B"; "%7C"; "%7D"; "%7E" };
|
||||
|
||||
:for I from=0 to=([ :len $Input ] - 1) do={
|
||||
:local Char [ :pick $Input $I ];
|
||||
:local Replace [ :find $Chars $Char ];
|
||||
|
||||
:if ([ :typeof $Replace ] = "num") do={
|
||||
:set Char ($Subs->$Replace);
|
||||
}
|
||||
:set Return ($Return . $Char);
|
||||
}
|
||||
|
||||
:return $Return;
|
||||
}
|
||||
|
||||
# basic syntax validation
|
||||
:set ValidateSyntax do={
|
||||
:local Code [ :tostr $1 ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue