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

Closed
opened 2026-02-21 18:12:51 -05:00 by yindo · 3 comments
Owner

Originally created by @QichangZheng on GitHub (Sep 28, 2024).

Originally assigned to: @takatost on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

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

Originally created by @QichangZheng on GitHub (Sep 28, 2024). Originally assigned to: @takatost on GitHub. ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### 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](https://github.com/user-attachments/assets/d4330d5d-a1fc-469a-a04c-b48530dc2849) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:12:51 -05:00
yindo closed this issue 2026-02-21 18:12:51 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 28, 2024):

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.

@dosubot[bot] commented on GitHub (Sep 28, 2024): <!-- Answer --> 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: ```ts 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 `/` <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/datasets/create/step-two/escape.ts)</sup>. Additionally, there is a similar unsolved discussion on this topic that might provide more context: [Why this not work](https://github.com/langgenius/dify/discussions/8006) <sup>[[2]](https://github.com/langgenius/dify/discussions/8006)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@iamjoel commented on GitHub (Sep 28, 2024):

@takatost
image

@iamjoel commented on GitHub (Sep 28, 2024): @takatost <img width="619" alt="image" src="https://github.com/user-attachments/assets/d9229e3c-0c1f-4cc4-9ae8-1ffe05b8677a">
Author
Owner

@crazywoola commented on GitHub (Oct 16, 2024):

This is filtered by the Cloudflare policy.

@crazywoola commented on GitHub (Oct 16, 2024): This is filtered by the Cloudflare policy.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5846