1***@qq.com
1***@qq.com
  • 发布:2023-09-13 17:10
  • 更新:2023-09-13 19:52
  • 阅读:87

【报Bug】保存字符串 onProgress=console.log 到数据库的时候报错

分类:uniCloud

产品分类: uniCloud/App

操作步骤:

云函数就一句保存 let addId = await collection.add(event),请求体对象 let obj = {
content: "<p>onProgress=console.log<br/></p>",
id: "",
title: "测试",
type: 1,
uploadimg: "",
}

预期结果:

{
"affectedDocs": 1,
"data": [
{
"_id": "65017aec189f866d652177be",
"id": 164,
"title": "测试",
"content": "<p>onProgress=console.log<br/></p>",
"type": 1,
"userid": 1,
"uploadimg": ""
}
]
}

实际结果:

{
"code": "FUNCTION_EXCUTE_ERROR",
"message": "Unexpected token < in JSON at position 0 (data json format: \"<!DOCTYPE html>\n<html lang=\\"zh-cn\\">\n\n<head>\n <meta charset=\\"utf-8\\">\n <meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=edge,chrome=1\\">\n <meta name=\\"data-spm\\" content=\\"a3c0e\\" />\n <title>405</title>\n <style>\n html, body, div, a, h2, p { margin: 0; padding: 0; }\n a { text-decoration: none; color: #3b6ea3; }\n .container { width: 1000px; margin: auto; color: #696969; }\n .header { padding: 50px 0; }\n .header .message { height: 36px; padding-left: 120px; background: url(https://errors.aliyun.com\" ...skip... \"};\n own.report = function() {\n // SPM\n own.alert();\n };\n own.alert = function() {\n alertShadow.style.display = 'block';\n alertContainer.style.display = 'block';\n };\n own.close = function() {\n alertShadow.style.display = 'none';\n alertContainer.style.display = 'none';\n };\n };\n </script>\n <script type=\\"text/javascript\\" charset=\\"utf-8\\" src=\\"https://errors.aliyun.com/error.js?\n2760820916945957158517007ed11c\\"></script>\n</body>\n\n</html>\n\"), POST https://api.next.bspapp.com/server 405 (connected: true, keepalive socket: false, socketHandledRequests: 1, socketHandledResponses: 1)\nheaders: {\"server\":\"Tengine\",\"date\":\"Wed, 13 Sep 2023 09:01:55 GMT\",\"content-type\":\"text/html; charset=utf-8\",\"transfer-encoding\":\"chunked\",\"connection\":\"keep-alive\",\"set-cookie\":[\"acw_tc=2760820916945957158517007ed11cd36bcb78bcc083406e16915178a05c06;path=/;HttpOnly;Max-Age=1800\"],\"cache-control\":\"no-cache, no-store\",\"pragma\":\"no-cache\"}"
}

bug描述:

云函数url化,然后在h5发送请求,请求体对象 带有 content: "<p>onProgress=console.log<br/></p>",就报错,如果是onProgress=console.lo就没事,就是少一个字母都不会报错,如果是 onProgress=console.log 就报 500

2023-09-13 17:10 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

连云端云函数的时候会报错吗?

  • 1***@qq.com (作者)

    本地和云函数都会报错

    2023-09-15 12:19

  • DCloud_uniCloud_WYQ

    回复 1***@qq.com: 收到我们找阿里反馈下

    2023-09-15 16:10

要回复问题请先登录注册