fix(web): escape document separator (#2870)

This commit is contained in:
alanchen
2025-08-01 17:47:29 +08:00
committed by GitHub
parent 154b6927fa
commit 26bb07f9d1
51 changed files with 81 additions and 63 deletions

View File

@@ -73,6 +73,19 @@ export default function Segmentation(props: IProps) {
}
};
const unescapeParamValue = (value: string) => {
if (typeof value !== 'string') {
return value;
}
return value
.replace(/\\n/g, '\n') // \n
.replace(/\\t/g, '\t') // \t
.replace(/\\r/g, '\r') // \r
.replace(/\\"/g, '"') // \" -> "
.replace(/\\'/g, "'") // \' -> '
.replace(/\\\\/g, '\\'); // \\ -> \
};
function checkParameter(data: FieldType) {
let checked = true;
if (syncStatus === 'RUNNING') {
@@ -94,7 +107,12 @@ export default function Segmentation(props: IProps) {
// remove unused parameter, otherwise api will failed.
strategy.parameters.forEach(param => {
const paramName = param.param_name;
newParam[paramName] = (item?.chunk_parameters as any)[paramName];
let paramValue = (item?.chunk_parameters as any)[paramName];
if (param.param_type === 'string' && typeof paramValue === 'string') {
paramValue = unescapeParamValue(paramValue);
}
newParam[paramName] = paramValue;
});
}
item.chunk_parameters = newParam;