gpt4 book ai didi

security - 总是在 View 中转义输出?为什么?

转载 作者:行者123 更新时间:2023-12-02 21:56:56 25 4
gpt4 key购买 nike

Zend Framework Manual说如下:

60.3.1. Escaping Output

One of the most important tasks to perform in a view script is to make sure that output is escaped properly; among other things, this helps to avoid cross-site scripting attacks. Unless you are using a function, method, or helper that does escaping on its own, you should always escape variables when you output them.

为什么“总是”?为什么我必须转义尚未由用户输入创建或更改的变量?

最佳答案

用户并不是输出中可疑字符串的唯一来源。例如,考虑来自数据库的明显安全的字符串“Romeo & Juliet”。你说那里没有跨站点脚本?确实如此。然而,将其放在网页中,原始的 & 符号可能会导致验证、解析等方面出现一些有趣的问题。

输出转义不仅仅是为了防止恶意或意外中断的输入,它还确保输出被彻底净化并被视为在周围的输出格式中没有特殊含义,无论是 HTML、XML、JSON 还是其他格式。

关于security - 总是在 View 中转义输出?为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1102429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com