如何在git URL中转义`@`密码等-附http的url特殊字符转义表

Excuses:
I see this: Escape @ character in git proxy password But It's about http.proxy param, and p%4055 does not work for me about url param.

My question:
I use git version 1.7.1
My password repository is: p@55
And I use gitlab server, and centos for client.
In .git/config file, i have be like this:

[remote "origin"]
url = http://user:p@55@domain.com:port/repo.git

But when I pull it, Gave me this error:

error: Couldn't resolve host '55:domain.com' while accessing ...

I know about escape @ char, but:

I try p\@55, Gave me this error:

fatal: bad config file line 8 in .git/config

I try p%4055, Gave me this error:

error: The requested URL returned error: 401 while accessing ...

I just upgrade git version from 1.7.1 to 2.11.1 and this worked for me:

url = http://user:p%4055@domain.com:port/repo.git

http url特殊字符转义

哪些字符需要编码

1、URL特殊字符转义,URL中一些字符的特殊含义,基本编码规则如下:

1、空格换成加号(+)
2、正斜杠(/)分隔目录和子目录
3、问号(?)分隔URL和查询
4、百分号(%)制定特殊字符
5、#号指定书签
6、&号分隔参数

2、不需要编码的字符:

RFC3986文档对Url的编解码问题做出了详细的建议,指出了哪些字符需要被编码才不会引起Url语义的转变,以及对为什么这些字符需要编码做出了相应的解释。

1、在US-ASCII字符集中没有的可打印字符:Url中只允许使用可打印字符。US-ASCII码中的10-7F字节全都表示控制字符,这些字符都不能直接出现在Url中。同时,对于80-FF字节(ISO-8859-1),由于已经超出了US-ACII定义的字节范围,因此也不可以放在Url中。

2、保留字符:Url可以划分成若干个组件,协议、主机、路径等。有一些字符(:/?#[]@)是用作分隔不同组件的。例如:冒号用于分隔协议和主机,/用于分隔主机和路径,?用于分隔路径和查询参数,等等。还有一些字符(!$&'()*+,;=)用于在每个组件中起到分隔作用的,如=用于表示查询参数中的键值对,&符号用于分隔查询多个键值对。当组件中的普通数据包含这些特殊字符时,需要对其进行编码。

RFC3986文档规定,Url中只允许包含以下四种:

                   1、英文字母(a-zA-Z)

                   2、数字(0-9)

                   3、-_.~ 4个特殊字符

                   4、所有保留字符,RFC3986中指定了以下字符为保留字符(英文字符):     ! * ' ( ) ; : @ & = + $ , / ? # [ ]

在使用get方式提交表单数据时,如果不对参数中的特殊字符做处理就会产生解析错误的问题。特殊字符的转义是通过将字符转换为对应的ASCII码的十六进制数字表示,然后再前面加上“%”,具体如下表。

字符URL编码
(空格)%20
"%22
#%23
%%25
&%26
(%28
)%29
+%2B
,%2C
/%2F
:%3A
;%3B
<%3C
=%3D
>%3E
?%3F
@%40
\%5C
|%7C

 

@ECHO OFF echo ^<?xml version="1.0" encoding="UTF-8"?^> > pom.xml echo ^<project xmlns="http://maven.apache.org/POM/4.0.0" >> pom.xml echo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> pom.xml echo xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"^> >> pom.xml echo ^<modelVersion^>4.0.0^</modelVersion^> >> pom.xml echo ^<packaging^>pom^</packaging^> >> pom.xml echo ^<groupId^>com.tplink.smb.omada^</groupId^> >> pom.xml echo ^<artifactId^>omada^</artifactId^> >> pom.xml echo ^<version^>5.0.0^</version^> >> pom.xml echo ^<properties^> >> pom.xml echo ^<java.version^>1.8^</java.version^> >> pom.xml echo ^</properties^> >> pom.xml echo ^<modules^> >> pom.xml echo ^<module^>omada_sdn_controller_microservice^</module^>" >> pom.xml echo ^<module^>omada_web^</module^> >> pom.xml echo ^<module^>omada_api_gateway^</module^> >> pom.xml echo ^<module^>omada_client^</module^> >> pom.xml echo ^<module^>omada_components^</module^> >> pom.xml echo ^<module^>omada_device_gateway^</module^> >> pom.xml echo ^<module^>omada_identityaccess^</module^> >> pom.xml echo ^<module^>omada_log^</module^> >> pom.xml echo ^<module^>omada_manager^</module^> >> pom.xml echo ^<module^>omada_monitor^</module^> >> pom.xml echo ^<module^>omada_maintenance^</module^> >> pom.xml echo ^<module^>omada_starter^</module^> >> pom.xml echo ^<module^>omada_insight^</module^> >> pom.xml echo ^</modules^> >> pom.xml echo ^</project^> >> pom.xml SET JAVA_HOME=%java_path% echo %JAVA_HOME% "%JAVA_HOME%\bin\java.exe" -version SET PATH=%JAVA_HOME%/bin;%maven_path%;%PATH% echo %PATH% call mvn -v REM 运行sonarqube分析 REM %maven_path%mvn.cmd clean verify -Plocal-build -Prelease-win -Psmb-nexus -Dmaven.test.skip=true org.sonarsource.scanner.maven:sonar-maven-plugin:3.11.0.3922:sonar -Dsonar.scm.disabled=true -#Dsonar.projectKey=win_%version% -Dsonar.projectName=win_%version% -Dsonar.host.url=http://10.42.20.74 -Dsonar.token=2c0b2622199955495c5e478acac658353bbcaa14 -pl !omada_web REM 强制刷新parent REM cd omada_sdn_controller_microservice REM %maven_path%mvn.cmd install REM cd .. echo Skip_Web=%Skip_Web% IF "%Skip_Web%"=="true" ( %maven_path%mvn.cmd clean install -Plocal-build -Prelease-win -Poversea -Psmb-nexus -Dmaven.test.skip=true -U -T1C -pl !omada_web ) else ( %maven_path%mvn.cmd clean install -Plocal-build -Prelease-win -Poversea -Psmb-nexus -Dmaven.test.skip=true -U -T1C ) REM 拷贝到深圳-美国中转目录中,加速Windows安装包服务器下载 SET PACKAGE_PATH=Z:\windows_packages\omada-standard\%BUILD_NUMBER% MKDIR %PACKAGE_PATH% COPY omada_starter\local-starter\target\*.zip %PACKAGE_PATH% 这段代码什么意思
最新发布
10-28
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值