Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Potential fix for code scanning alert no. 71: Incomplete URL substring sanitization (#13318)

Yingfenga806f7b70772
diff --git a/web/src/pages/user-setting/setting-model/hooks.tsx b/web/src/pages/user-setting/setting-model/hooks.tsx
index 72bd087042..fe233e0577 100644
--- a/web/src/pages/user-setting/setting-model/hooks.tsx
+++ b/web/src/pages/user-setting/setting-model/hooks.tsx
@@ -49,11 +49,23 @@ export const useSubmitApiKey = () => {
verify: isVerify,
};
if (savingParams.llm_factory === LLMFactory.SILICONFLOW) {
- payload.source_fid = (postBody.base_url || '')
- .toLowerCase()
- .includes('api.siliconflow.com')
- ? 'siliconflow_intl'
- : LLMFactory.SILICONFLOW;
+ let sourceFid = LLMFactory.SILICONFLOW;
+ const baseUrl = postBody.base_url;
+ if (baseUrl) {
+ try {
+ const parsed = new URL(baseUrl);
+ const host = parsed.hostname.toLowerCase();
+ if (
+ host === 'api.siliconflow.com' ||
+ host.endsWith('.api.siliconflow.com')
+ ) {
+ sourceFid = 'siliconflow_intl';
+ }
+ } catch {
+ // ignore invalid URL and keep default sourceFid
+ }
+ }
+ payload.source_fid = sourceFid;
}
const ret = await saveApiKey(payload);