Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): disable HTML escaping for form field validation messages (#31292)

yyh54921844bb34
diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsx
index 19977c8c50c..553836d73cc 100644
--- a/web/app/components/app/annotation/index.tsx
+++ b/web/app/components/app/annotation/index.tsx
@@ -203,7 +203,7 @@ const Annotation: FC<Props> = (props) => {
</Filter>
{isLoading
? <Loading type="app" />
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: total > 0
? (
<List
diff --git a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
index 24281dd7535..f5ebaac3ca6 100644
--- a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
+++ b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx
@@ -134,7 +134,6 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
},
] as const
- // eslint-disable-next-line sonarjs/no-nested-template-literals, sonarjs/no-nested-conditional
const [instructionFromSessionStorage, setInstruction] = useSessionStorageState<string>(`improve-instruction-${flowId}${isBasicMode ? '' : `-${nodeId}${editorId ? `-${editorId}` : ''}`}`)
const instruction = instructionFromSessionStorage || ''
const [ideaOutput, setIdeaOutput] = useState<string>('')
diff --git a/web/app/components/app/overview/settings/index.spec.tsx b/web/app/components/app/overview/settings/index.spec.tsx
index 41d86047f00..776c55d149e 100644
--- a/web/app/components/app/overview/settings/index.spec.tsx
+++ b/web/app/components/app/overview/settings/index.spec.tsx
@@ -175,7 +175,7 @@ describe('SettingsModal', () => {
renderSettingsModal()
fireEvent.click(screen.getByText('appOverview.overview.appInfo.settings.more.entry'))
const privacyInput = screen.getByPlaceholderText('appOverview.overview.appInfo.settings.more.privacyPolicyPlaceholder')
- // eslint-disable-next-line sonarjs/no-clear-text-protocols
+
fireEvent.change(privacyInput, { target: { value: 'ftp://invalid-url' } })
fireEvent.click(screen.getByText('common.operation.save'))
diff --git a/web/app/components/base/markdown-blocks/code-block.tsx b/web/app/components/base/markdown-blocks/code-block.tsx
index 79a374e2919..b9b30743519 100644
--- a/web/app/components/base/markdown-blocks/code-block.tsx
+++ b/web/app/components/base/markdown-blocks/code-block.tsx
@@ -205,7 +205,7 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
}
catch {
try {
- // eslint-disable-next-line no-new-func, sonarjs/code-eval
+ // eslint-disable-next-line no-new-func
const result = new Function(`return ${trimmedContent}`)()
if (typeof result === 'object' && result !== null) {
setFinalChartOption(result)
@@ -250,7 +250,7 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
}
catch {
try {
- // eslint-disable-next-line no-new-func, sonarjs/code-eval
+ // eslint-disable-next-line no-new-func
const result = new Function(`return ${trimmedContent}`)()
if (typeof result === 'object' && result !== null) {
setFinalChartOption(result)
diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
index df41e8c1e75..8fe6af6170b 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
@@ -28,10 +28,10 @@ const RuleDetail = ({
case 'mode':
value = !sourceData?.mode
? value
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: sourceData.mode === ProcessMode.general
? (t('embedding.custom', { ns: 'datasetDocuments' }) as string)
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: `${t('embedding.hierarchical', { ns: 'datasetDocuments' })} · ${sourceData?.rules?.parent_mode === 'paragraph'
? t('parentMode.paragraph', { ns: 'dataset' })
: t('parentMode.fullDoc', { ns: 'dataset' })}`
@@ -70,7 +70,7 @@ const RuleDetail = ({
src={
retrievalMethod === RETRIEVE_METHOD.fullText
? retrievalIcon.fullText
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: retrievalMethod === RETRIEVE_METHOD.hybrid
? retrievalIcon.hybrid
: retrievalIcon.vector
diff --git a/web/app/components/datasets/settings/form/index.tsx b/web/app/components/datasets/settings/form/index.tsx
index 206c264a88d..6081a36fcc8 100644
--- a/web/app/components/datasets/settings/form/index.tsx
+++ b/web/app/components/datasets/settings/form/index.tsx
@@ -403,7 +403,7 @@ const Form = () => {
</div>
</>
)
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: indexMethod
? (
<>
diff --git a/web/app/components/tools/edit-custom-collection-modal/get-schema.spec.tsx b/web/app/components/tools/edit-custom-collection-modal/get-schema.spec.tsx
index de156ce68a4..fa316c4aab7 100644
--- a/web/app/components/tools/edit-custom-collection-modal/get-schema.spec.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/get-schema.spec.tsx
@@ -23,7 +23,7 @@ describe('GetSchema', () => {
it('shows an error when the URL is not http', () => {
fireEvent.click(screen.getByText('tools.createTool.importFromUrl'))
const input = screen.getByPlaceholderText('tools.createTool.importFromUrlPlaceHolder')
- // eslint-disable-next-line sonarjs/no-clear-text-protocols
+
fireEvent.change(input, { target: { value: 'ftp://invalid' } })
fireEvent.click(screen.getByText('common.operation.ok'))
diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts
index e5e81744566..2f83945dc2d 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts
+++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts
@@ -474,7 +474,6 @@ const formatItem = (
break
}
- // eslint-disable-next-line sonarjs/no-duplicated-branches
case BlockEnum.VariableAggregator: {
const { output_type, advanced_settings }
= data as VariableAssignerNodeType
@@ -1875,7 +1874,7 @@ export const updateNodeVars = (
}
break
}
- // eslint-disable-next-line sonarjs/no-duplicated-branches
+
case BlockEnum.VariableAggregator: {
const payload = data as VariableAssignerNodeType
if (payload.variables) {
diff --git a/web/app/components/workflow/nodes/data-source/panel.tsx b/web/app/components/workflow/nodes/data-source/panel.tsx
index f29c37d16d2..eb233c01c82 100644
--- a/web/app/components/workflow/nodes/data-source/panel.tsx
+++ b/web/app/components/workflow/nodes/data-source/panel.tsx
@@ -139,20 +139,22 @@ const Panel: FC<NodePanelProps<DataSourceNodeType>> = ({ id, data }) => {
return (
<div key={outputItem.name}>
- {outputItem.value?.type === 'object' ? (
- <StructureOutputItem
- rootClassName="code-sm-semibold text-text-secondary"
- payload={wrapStructuredVarItem(outputItem, schemaType)}
- />
- ) : (
- <VarItem
- name={outputItem.name}
- // eslint-disable-next-line sonarjs/no-nested-template-literals
- type={`${outputItem.type.toLocaleLowerCase()}${schemaType ? ` (${schemaType})` : ''}`}
- description={outputItem.description}
- isIndent={hasObjectOutput}
- />
- )}
+ {outputItem.value?.type === 'object'
+ ? (
+ <StructureOutputItem
+ rootClassName="code-sm-semibold text-text-secondary"
+ payload={wrapStructuredVarItem(outputItem, schemaType)}
+ />
+ )
+ : (
+ <VarItem
+ name={outputItem.name}
+
+ type={`${outputItem.type.toLocaleLowerCase()}${schemaType ? ` (${schemaType})` : ''}`}
+ description={outputItem.description}
+ isIndent={hasObjectOutput}
+ />
+ )}
</div>
)
})}
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
index e7860d2fb23..c3eef42a39d 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
@@ -100,7 +100,7 @@ const RetrievalConfig: FC<Props> = ({
score_threshold: configs.score_threshold_enabled ? (configs.score_threshold ?? DATASET_DEFAULT.score_threshold) : null,
reranking_model: retrieval_mode === RETRIEVE_TYPE.oneWay
? undefined
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: (!configs.reranking_model?.reranking_provider_name
? undefined
: {
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts b/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts
index a30ec8e7356..2ce57bc270f 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts
@@ -135,7 +135,7 @@ export const getMultipleRetrievalConfig = (
vector_setting: {
vector_weight: allHighQualityVectorSearch
? DEFAULT_WEIGHTED_SCORE.allHighQualityVectorSearch.semantic
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: allHighQualityFullTextSearch
? DEFAULT_WEIGHTED_SCORE.allHighQualityFullTextSearch.semantic
: DEFAULT_WEIGHTED_SCORE.other.semantic,
@@ -145,7 +145,7 @@ export const getMultipleRetrievalConfig = (
keyword_setting: {
keyword_weight: allHighQualityVectorSearch
? DEFAULT_WEIGHTED_SCORE.allHighQualityVectorSearch.keyword
- // eslint-disable-next-line sonarjs/no-nested-conditional
+
: allHighQualityFullTextSearch
? DEFAULT_WEIGHTED_SCORE.allHighQualityFullTextSearch.keyword
: DEFAULT_WEIGHTED_SCORE.other.keyword,
@@ -232,7 +232,6 @@ export const getMultipleRetrievalConfig = (
result.reranking_mode = RerankingModeEnum.RerankingModel
result.reranking_enable = true
- // eslint-disable-next-line sonarjs/nested-control-flow
if ((!result.reranking_model?.provider || !result.reranking_model?.model) && isFallbackRerankModelValid) {
result.reranking_model = {
provider: fallbackRerankModel.provider || '',
diff --git a/web/app/components/workflow/nodes/tool/panel.tsx b/web/app/components/workflow/nodes/tool/panel.tsx
index 9ff649b2079..899a26ff4fb 100644
--- a/web/app/components/workflow/nodes/tool/panel.tsx
+++ b/web/app/components/workflow/nodes/tool/panel.tsx
@@ -124,20 +124,22 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
// TODO empty object type always match `qa_structured` schema type
return (
<div key={outputItem.name}>
- {outputItem.value?.type === 'object' ? (
- <StructureOutputItem
- rootClassName="code-sm-semibold text-text-secondary"
- payload={wrapStructuredVarItem(outputItem, schemaType)}
- />
- ) : (
- <VarItem
- name={outputItem.name}
- // eslint-disable-next-line sonarjs/no-nested-template-literals
- type={`${outputItem.type.toLocaleLowerCase()}${schemaType ? ` (${schemaType})` : ''}`}
- description={outputItem.description}
- isIndent={hasObjectOutput}
- />
- )}
+ {outputItem.value?.type === 'object'
+ ? (
+ <StructureOutputItem
+ rootClassName="code-sm-semibold text-text-secondary"
+ payload={wrapStructuredVarItem(outputItem, schemaType)}
+ />
+ )
+ : (
+ <VarItem
+ name={outputItem.name}
+
+ type={`${outputItem.type.toLocaleLowerCase()}${schemaType ? ` (${schemaType})` : ''}`}
+ description={outputItem.description}
+ isIndent={hasObjectOutput}
+ />
+ )}
</div>
)
})}
diff --git a/web/app/components/workflow/note-node/note-editor/utils.ts b/web/app/components/workflow/note-node/note-editor/utils.ts
index dff98a83017..22cfc3726a6 100644
--- a/web/app/components/workflow/note-node/note-editor/utils.ts
+++ b/web/app/components/workflow/note-node/note-editor/utils.ts
@@ -18,5 +18,4 @@ export function getSelectedNode(
return $isAtNodeEnd(anchor) ? anchorNode : focusNode
}
-// eslint-disable-next-line sonarjs/empty-string-repetition
export const urlRegExp = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*)?)/
diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json
index 755ea07f56d..4f274115c82 100644
--- a/web/eslint-suppressions.json
+++ b/web/eslint-suppressions.json
@@ -3280,9 +3280,6 @@
}
},
"app/components/workflow/nodes/data-source/panel.tsx": {
- "style/multiline-ternary": {
- "count": 2
- },
"ts/no-explicit-any": {
"count": 3
}
@@ -3665,9 +3662,6 @@
}
},
"app/components/workflow/nodes/tool/panel.tsx": {
- "style/multiline-ternary": {
- "count": 2
- },
"ts/no-explicit-any": {
"count": 2
}
diff --git a/web/i18n-config/settings.ts b/web/i18n-config/settings.ts
index 1bf37ab21d5..ea2a8a00588 100644
--- a/web/i18n-config/settings.ts
+++ b/web/i18n-config/settings.ts
@@ -9,5 +9,8 @@ export function getInitOptions(): InitOptions {
partialBundledLanguages: true,
keySeparator: false,
ns: namespacesCamelCase,
+ interpolation: {
+ escapeValue: false,
+ },
}
}
diff --git a/web/scripts/analyze-i18n-diff.ts b/web/scripts/analyze-i18n-diff.ts
index 9fd5f3b4a79..bd830c55237 100644
--- a/web/scripts/analyze-i18n-diff.ts
+++ b/web/scripts/analyze-i18n-diff.ts
@@ -106,7 +106,7 @@ function parseTsContent(content: string): NestedTranslation {
// Use Function constructor to safely evaluate the object literal
// This handles JS object syntax like unquoted keys, template literals, etc.
try {
- // eslint-disable-next-line no-new-func, sonarjs/code-eval
+ // eslint-disable-next-line no-new-func
const fn = new Function(`return (${cleaned})`)
return fn() as NestedTranslation
}
@@ -123,7 +123,7 @@ function parseTsContent(content: string): NestedTranslation {
function getMainBranchFile(filePath: string): string | null {
try {
const relativePath = `./i18n/${LOCALE}/${filePath}`
- // eslint-disable-next-line sonarjs/os-command
+
return execSync(`git show main:${relativePath}`, {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
@@ -148,12 +148,12 @@ function getTranslationFiles(): string[] {
function getMainBranchNamespaces(): string[] {
try {
const relativePath = `./i18n/${LOCALE}`
- // eslint-disable-next-line sonarjs/os-command
+
const output = execSync(`git ls-tree --name-only main ${relativePath}/`, {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
})
- // eslint-disable-next-line sonarjs/os-command
+
return output
.trim()
.split('\n')