diff --git a/js/mzta-utils.js b/js/mzta-utils.js index c6f95900..bd03c835 100644 --- a/js/mzta-utils.js +++ b/js/mzta-utils.js @@ -415,6 +415,10 @@ export function validateChatGPTWebCustomData(data) { return data.startsWith('/g/') || data == ''; } +export function sanitizeChatGPTModelData(input) { + return encodeURIComponent(input).toLowerCase() +} + export function sanitizeChatGPTWebCustomData(input) { // Removes all characters that are not letters, numbers, dashes, or slashes return input.replace(/[^\p{L}\p{N}\/-]+/gu, ''); diff --git a/options/mzta-options.js b/options/mzta-options.js index 9f8e36a0..e169bfca 100644 --- a/options/mzta-options.js +++ b/options/mzta-options.js @@ -22,7 +22,7 @@ import { OpenAI } from '../js/api/openai.js'; import { Ollama } from '../js/api/ollama.js'; import { OpenAIComp } from '../js/api/openai_comp.js' import { GoogleGemini } from '../js/api/google_gemini.js'; -import { checkSparksPresence, isThunderbird128OrGreater, openTab, validateChatGPTWebCustomData, sanitizeChatGPTWebCustomData } from '../js/mzta-utils.js'; +import { checkSparksPresence, isThunderbird128OrGreater, openTab, validateChatGPTWebCustomData, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData } from '../js/mzta-utils.js'; let taLog = new taLogger("mzta-options",true); let _isThunderbird128OrGreater = true; @@ -689,7 +689,7 @@ document.addEventListener('DOMContentLoaded', async () => { let webproject_set = false; if((prefs_mod.chatgpt_web_model != '') && (prefs_mod.chatgpt_web_model != undefined)){ - model_opt = '?model=' + encodeURIComponent(prefs_mod.chatgpt_web_model).toLowerCase(); + model_opt = '?model=' + sanitizeChatGPTModelData(prefs_mod.chatgpt_web_model); } if((prefs_mod.chatgpt_web_project != '') && (prefs_mod.chatgpt_web_project != undefined)){ base_url += sanitizeChatGPTWebCustomData(prefs_mod.chatgpt_web_project);