langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
51.81k stars 7.51k forks source link

Does not work with input like '/xx/xx' #8860

Closed QichangZheng closed 1 month ago

QichangZheng commented 1 month ago

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. image

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

dosubot[bot] commented 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.

iamjoel commented 1 month ago

@takatost

image
crazywoola commented 1 month ago

This is filtered by the Cloudflare policy.