mirror of
https://github.com/langgenius/dify.git
synced 2026-07-27 23:18:33 +08:00
fix(web): support punctuation in markdown form field names (#38651)
This commit is contained in:
parent
489e77658e
commit
3c8e0e2113
@ -534,6 +534,26 @@ describe('MarkdownForm', () => {
|
||||
|
||||
// Unicode letters should be valid form field names.
|
||||
describe('Unicode name support', () => {
|
||||
it('should include fields whose names contain supported full-width and half-width punctuation', async () => {
|
||||
const user = userEvent.setup()
|
||||
const node = createRootNode(
|
||||
[
|
||||
createElementNode('input', { type: 'hidden', name: '字段()!*&-', value: 'full-width' }),
|
||||
createElementNode('input', { type: 'hidden', name: 'field()!*&-', value: 'half-width' }),
|
||||
createElementNode('button', {}, [createTextNode('Submit')]),
|
||||
],
|
||||
{ dataFormat: 'json' },
|
||||
)
|
||||
|
||||
render(<MarkdownForm node={node} />)
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Submit' }))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockOnSend).toHaveBeenCalledWith('{"字段()!*&-":"full-width","field()!*&-":"half-width"}')
|
||||
})
|
||||
})
|
||||
|
||||
it('should include Unicode-named fields from all supported controls in JSON output', async () => {
|
||||
const user = userEvent.setup()
|
||||
const node = createRootNode(
|
||||
|
||||
@ -43,7 +43,7 @@ const SUPPORTED_TYPES_SET = new Set<string>(Object.values(SUPPORTED_TYPES))
|
||||
|
||||
const SAFE_NAME_RE = (() => {
|
||||
try {
|
||||
return new RegExp('^\\p{L}[\\p{L}\\p{M}\\p{N}_-]*$', 'u')
|
||||
return new RegExp('^\\p{L}[\\p{L}\\p{M}\\p{N}_()!*&()!*&--]*$', 'u')
|
||||
}
|
||||
catch {
|
||||
// Fallback for browsers without Unicode property escape support.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user