首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >curl -如何转义< in参数值

curl -如何转义< in参数值
EN

Stack Overflow用户
提问于 2014-08-25 10:53:23
回答 1查看 2K关注 0票数 2

下面是我正在执行的curl命令

代码语言:javascript
运行
复制
curl -F "context=<http://example.com>" \
     -F "Content-Type=text/plain" \
     -F "source=file" \
     -F "content=@members.nt;type=text/plain" \
     http://localhost:8080/openrdf-workbench/repositories/XXX/add

我正在尝试加载openrdf存储库。它给了我一个错误,因为在"context“参数的值中有一个"<”字符。如何转义这个"<“以便curl不认为我试图将文件内容加载到"context”参数中

curl的错误是:

代码语言:javascript
运行
复制
curl: (26) couldn't open file "http://example.com>"

我尝试用\并使用<和%3C来转义它,但是没有运气,因为一旦我尝试这样做,另一端就是抱怨它没有得到确切的http://example.com

这就是从浏览器表单发送的内容。

代码语言:javascript
运行
复制
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="baseURI"


------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="context"

<http://example.com>
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="Content-Type"

text/plain
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="source"

file
------WebKitFormBoundaryl8CUSIvy5962lwBF
Content-Disposition: form-data; name="content"; filename="members.nt"
Content-Type: application/octet-stream


------WebKitFormBoundaryl8CUSIvy5962lwBF--  

有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-25 11:12:11

您可以使用curl的--form-string,它类似于-F,但不解释引导@<

代码语言:javascript
运行
复制
   --form-string <name=string>
          (HTTP)  Similar  to --form except that the value string for the named parameter is used literally. Leading '@' and '<' characters, and the ';type=' string in the value have
          no special meaning. Use this in preference to --form if there's any possibility that the string value may accidentally trigger the '@' or '<' features of --form.
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25484313

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档