Closed QichangZheng closed 1 month ago
There is a known issue with handling special characters in user inputs, including characters like /
. The escape
function in the code handles several special characters by escaping them, but it does not specifically handle the /
character. Here is the relevant code snippet:
function escape(input: string): string {
if (!input || typeof input !== 'string')
return ''
const res = input
.replaceAll('\\', '\\\\')
.replaceAll('\0', '\\0')
.replaceAll('\b', '\\b')
.replaceAll('\f', '\\f')
.replaceAll('\n', '\\n')
.replaceAll('\r', '\\r')
.replaceAll('\t', '\\t')
.replaceAll('\v', '\\v')
.replaceAll('\'', '\\\'')
return res
}
export default escape
This function handles characters like \
, \0
, \b
, \f
, \n
, \r
, \t
, \v
, and '
, but not /
[1].
Additionally, there is a similar unsolved discussion on this topic that might provide more context: Why this not work [2].
To continue talking to Dosu, mention @dosu.
@takatost
This is filtered by the Cloudflare policy.
Self Checks
Dify version
Official lastest
Cloud or Self Hosted
Cloud
Steps to reproduce
In the basic app gpt-4o-mini, when I ask 'What is in /etc/services?', I got no response. It works well in other cases, it might be due to the failure of paring the json.
✔️ Expected Behavior
No response
❌ Actual Behavior
No response