quote env value to fix syntax error on multiline env#510
Merged
Conversation
Contributor
|
所以 #508 里这个例子输出是什么样的? |
Contributor
Author
|
jysperm
approved these changes
Jul 22, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #508
{{改为{{{来关闭 HTML 转义'https://github.com/cbroglie/mustache#escapingSET name=v a l中等号后面全部都视为值另外 shellescape 的实现也很有意思,它有一个白名单
\w@%+=:,./-,如果输入都在白名单内不做任何操作。如果出现了白名单外的字符,会在输入前后加单引号',因为 bash 中单引号字符串就是最纯粹的字符串,不会有插值之类的操作。唯一的问题就是如果输入本来就包含单引号会造成不匹配,而且无法通过用其他编程语言中常见的\'来表示,因为 bash 中 ANSI-C Quoting 需要用$''字符串才行。shellescape 中是利用了 C 系语言中字符串的一个特性:相邻的字面量字符串会自动拼接在一起:它会将原来存在的单引号
'替换成'"'"'(单双单双单)。两边的单引号用来配对之前对前后添加的单引号,中间是双引号中间的单引号"'",也就是长度为一的字符串。综上,原字符串a'b会变成三个字符串'a' "'" 'b'(添加了空格帮助阅读)。