样书配置
感谢您提供反馈

这篇文章已经过机器翻译.放弃

允许在样书中使用其文字形式的特殊字符

在样书定义中,当字符串中的特殊字符必须采用文字形式时,您可以使用逐字字符串。这些字符串可以包含转义字符、反斜杠、引号、括号、空格、括号等。

在样书中,您可以使用逐字字符串将 NetScaler 策略表达式包含在其文本形式中。策略表达式通常包含特殊字符。如果没有逐字字符串,您必须通过将字符串分成子字符串来转义特殊字符。

要创建逐字字符串,请将字符串封装在特殊字符之间,如下所示:

~{string}~

您可以在样书表达式中使用逐字字符串。

注意

不要在输入字符串中使用字符序列} ~,因为该序列表示逐字字符串的结尾。

示例

--- name: test-deny-url namespace: citrix.adc.stylebooks version: "6.2" display-name: StyleBook for creating an AppFw profile description: This Stylebook configures an AppFw config. schema-version: "1.0" import-stylebooks: - namespace: netscaler.nitro.config prefix: ns version: "13.0" parameters: - name: name type: string required: true substitutions: default-deny-urls-regex: "Command_injection_attack": str("([ /=]|\t|\n)(ls|cat)([ ;'" + "\\"&].\*)?$") "Command_injection_attack2": ~{([ /=]|\t|\n)(ls|rm|cat)([ ;'"&].\*)?$}~ components: - name: appfw-profile-comp type: ns::appfwprofile properties: name: $parameters.name type: ["XML"] components: - name: appfw-profile-denyurl-default-binding-subcomp-all type: ns::appfwprofile_denyurl_binding properties: name: $parent.properties.name denyurl?: $substitutions.default-deny-urls-regex["Command_injection_attack"] state?: "ENABLED" - name: appfw-profile-denyurl-default-binding-subcomp-all2 type: ns::appfwprofile_denyurl_binding properties: name: $parent.properties.name denyurl?: $substitutions.default-deny-urls-regex["Command_injection_attack2"] state?: "ENABLED"

在此示例中,default-deny-urls-regex 替换具有逐字表达式。

  • "Command_injection_attack": str("([ /=]|\\t|\\n)(ls|cat)([ ;'" + "\\\"&].*)?$"):样书将其作为正则表达式处理。

  • "Command_injection_attack2": ~{([ /=]|\t|\n)(ls|rm|cat)([ ;'\"&].*)?$}~:样书将其作为逐字表达式进行处理。此字符串中的特殊字符采用文字形式。

连接多个逐字字符串

您可以将逐字字符串与常规字符串或带插值的字符串连接起来。当您这样做时,样书只会跳过逐字字符串的解释。在字符串之间使用加号 (+) 运算符进行连接。

示例

value: "~{"id": "}~ + %{$atom.key}% + ~{", "value": "}~ + %{$atom.value}% + ~{"}~"

在此例子中,将解释 %{$atom.key}%%{$atom.value}%。而且,剩下的解释被跳过。

本内容的正式版本为英文版。部分 Cloud Software Group 文档内容采用了机器翻译,仅供您参考。Cloud Software Group 无法控制机器翻译的内容,这些内容可能包含错误、不准确或不合适的语言。对于从英文原文翻译成任何其他语言的内容的准确性、可靠性、适用性或正确性,或者您的 Cloud Software Group 产品或服务沿用了任何机器翻译的内容,我们均不作任何明示或暗示的保证,并且适用的最终用户许可协议或服务条款或者与 Cloud Software Group 签订的任何其他协议(产品或服务与已进行机器翻译的任何文档保持一致)下的任何保证均不适用。对于因使用机器翻译的内容而引起的任何损害或问题,Cloud Software Group 不承担任何责任。
允许在样书中使用其文字形式的特殊字符