【问题标题】:What does the express-validator escape() function?express-validator escape() 函数有什么作用?
【发布时间】:2022-10-17 21:45:04
【问题描述】:

express-validator escape() 消毒剂到底是什么?无法理解。例如:

check('name')
  .trim()
  .escape()
  .notEmpty()
  .withMessage('User name can not be empty!')
  .bail()
  .isLength({ min: 3 })
  .withMessage('Minimum 3 characters required!')
  .bail(),

为什么在 trim() 之后需要 escape()?

【问题讨论】:

标签: node.js express middleware


【解决方案1】:

感谢罗伯特克莱普。此处描述了每种消毒剂:

Sanitizers

【讨论】:

    【解决方案2】:

    有趣的是,它用 HTML 实体替换了 <、>、&、'、" 和 /。

    您可以参考这里:validatorjs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多