Description

This article explains the need to encode special characters when a URL is used as part of a command-line to ensure proper functionality.

Solution

The list of special characters and their corresponding encoding characters are listed below:

Character              Encoding to be used
space                     %20
!                              %21
"                              %22
#                             %23
$                              %24
%                            %25
&                             %26
'                               %27
(                              %28
)                              %29
*                             %2A
+                             %2B
,                               %2C
-                              %2D
.                               %2E
/                              %2F
:                               %3A
;                               %3B
<                             %3C
=                             %3D
>                             %3E
?                              %3F
@                            %40
[                             %5B
\                              %5C
]                              %5D
^                             %5E
_                             %5F
`                               %60
{                              %7B
|                              %7C
}                              %7D

For detailed list, refer to:  https://www.w3schools.com/tags/ref_urlencode.ASP

Example of Usage: 

When fetching a file to the router from local server:

Special character “+” need to be encoded in URL so it need to be replaced by  %2B.

user@host> request system software add no-copy no-validate ftp://uname:abcdefg+@ <server-ip> /jinstall-x-signed.tgz

NOTE: Since "@" is a part of the syntax format for accessing URL, there is no need to encode this character when it is used in "username:password @ server_ip" format. If "@" is being used elsewhere in the username/password, one must encode this character too. In that case, @ will be encoded as %40

Here, the username is uname and password is "abcdefg+"

When the above command is executed, you will see the followoing error message:

fetch: ftp://uname:*@ <server-ip> /jinstall-x-signed.tgz : Not logged in
ERROR: Cannot fetch file: jinstall-x-signed.tgz
Removing temporary file '/var/tmp/incoming-package.tgz'

Correct Usage:

user@host> request system software add no-copy no-validate  ftp://uname:abcdefg %2B @ <server-ip> /jinstall-x-signed.tgz

Here, abcdefg+ is represented as abcdefg%2B where %2B is the encoded format of "+".