庆典:注射可变进字符串增加了额外的\\ r [英] bash: injecting variable into string adds extra \r

查看:112
本文介绍了庆典:注射可变进字符串增加了额外的\\ r的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用卷曲将文件发送给我们的第三方的云文件存储的脚本。

I have a script that uses curl to send a file to our third party cloud file storage.

我使用grep拉出HTTP响应提供给我一个网址

I am using grep to pull out a URL provided to me in an http response

看起来像这样

curl -X PUT -T media/file.tar.gz -D - \
     -H "ETag: ${md5}" \
     -H "Content-Type: application/x-gzip" \
     -H "${AuthToken}" \
     -H "X-Object-Meta-Date: ${today}" \
     "${StorageUrl}/dp/file1.tar.gz"

然后我得到的网址错误请求
打印出像

and then I get a bad request on the url which prints out like

'PUT /v1/MossoCloudFS100213=123-123-1233a-ss9\r/dp/file1.tar.gz'

看到,只是烦人已注入我的变量和/ DP /?

see that \r that just annoyingly has been injected between my variable and the /dp/?

推荐答案

我猜,你有一个来自Web请求的 $ StorageUrl 值和网络响应行与止CRLF(web标准一般要求CRLF行结束)。外壳去掉LF(新行)你,但不是CR( \\ r ,回车)。你可能需要使用URL之前,采取照顾自己。

I guess that you got the $StorageUrl value from a web request and the web response line ended with CRLF (the web standards generally require CRLF line endings). The shell removed the LF (newline) for you, but not the CR (\r, carriage return). You'll probably need to take care of that yourself before using the URL.

这篇关于庆典:注射可变进字符串增加了额外的\\ r的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆