【问题标题】:Can IIS customTags access items other than the attribute of the tag?IIS customTags 可以访问标签属性以外的项目吗?
【发布时间】:2021-01-10 08:57:41
【问题描述】:

我想编写一个 IIS 重写规则来检测包含特定字符串的 <script> 标记。匹配<script> 的正常机制涉及匹配src。因此,我考虑过创建自定义标签,但事实证明这是有问题的。

根据我下载的据称是 IIS 手册的大型 PDF,customTags 可以定义如下:

<customTags>
  <tags name="My Tags">
    <tag name="item" attribute="src" />
    <tag name="element" attribute="src" />
  </tags>
</customTags>

最初,我认为也许有一个空属性可以让我访问脚本标签的内部文本。但是,指定

<customTags>
  <tags name="My Tags">
    <tag name="script" attribute="" />
  </tags>
</customTags>

引发错误。我还没有尝试将属性设置为“innerText”。这行得通吗?

【问题讨论】:

    标签: iis-8 url-rewrite-module


    【解决方案1】:

    您可以使用以下规则重写页面内容:

     <rule name="test" preCondition="IsHTML" stopProcessing="true">
                    <match pattern="style.fontSize = &quot;(.*)&quot;;" />
                    <action type="Rewrite" value="style.fontSize = &quot;30px&quot;;" />
                </rule>
    

    这是规则在 URL 重写中的样子:

    您无需从下拉列表中选择任何标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-26
      • 2013-06-22
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多