mirror of https://github.com/langgenius/dify.git
fix(web): disable HTML escaping for form field validation messages (#31292)
This commit is contained in:
parent
3ebe53ada1
commit
54921844bb
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>('')
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ const Form = () => {
|
|||
</div>
|
||||
</>
|
||||
)
|
||||
// eslint-disable-next-line sonarjs/no-nested-conditional
|
||||
|
||||
: indexMethod
|
||||
? (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
)
|
||||
})}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
: {
|
||||
|
|
|
|||
|
|
@ -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 || '',
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
)
|
||||
})}
|
||||
|
|
|
|||
|
|
@ -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*)?)/
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,5 +9,8 @@ export function getInitOptions(): InitOptions {
|
|||
partialBundledLanguages: true,
|
||||
keySeparator: false,
|
||||
ns: namespacesCamelCase,
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in New Issue