@@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
1212-->
1313
1414<script id="init-config">
15- const LITEVER = 284 ;
15+ const LITEVER = 285 ;
1616 const urlParams = new URLSearchParams(window.location.search);
1717 var localflag = urlParams.get('local'); //this will be replaced automatically in embedded kcpp
1818 const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@@ -4142,12 +4142,11 @@ Current version indicated by LITEVER below.
41424142 {
41434143 return !isNaN(parseFloat(n)) && isFinite(n);
41444144 }
4145+ function escapeRegExp(string) {
4146+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
4147+ }
41454148 function replaceAll(str, find, replace, caseInsensitive=false) //replace all occurances in string with string
41464149 {
4147- function escapeRegExp(string) {
4148- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
4149- }
4150-
41514150 return str.replace(new RegExp(escapeRegExp(find), (caseInsensitive?'gi':'g')), replace);
41524151 }
41534152 function rgb_to_hex(rgbColor) { //convert rgb color to hex
@@ -4939,7 +4938,9 @@ Current version indicated by LITEVER below.
49394938 {
49404939 return "";
49414940 }
4942- return `${localsettings.start_thinking_tag}([\\s\\S]*?)${localsettings.stop_thinking_tag}`;
4941+ const safeStart = escapeRegExp(localsettings.start_thinking_tag);
4942+ const safeStop = escapeRegExp(localsettings.stop_thinking_tag);
4943+ return `${safeStart}([\\s\\S]*?)${safeStop}`;
49434944 }
49444945
49454946 function remove_all_instruct_tags(text)
@@ -15135,7 +15136,7 @@ Current version indicated by LITEVER below.
1513515136 let matchiter = 0;
1513615137 inputtxt = inputtxt.replace(/%ExpandBtn%(?:\n{0,2})?/g, function (m) {
1513715138 let curr = matches[matchiter];
15138- let expandedhtml = `<span><button type="button" title="Show Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="toggle_hide_thinking(this)">Show Thoughts (${curr.length} characters)</button><span class="color_lightgreen hidden"><br>${escape_html(curr)}</span><br></span>`;
15139+ let expandedhtml = `<span><button type="button" title="Show Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="toggle_hide_thinking(this)">Show Thoughts (${curr.length} characters)</button><span class="color_lightgreen hidden"><br>${escape_html(curr)}\n </span><br></span>`;
1513915140 if(!curr || curr.trim()=="" || curr.trim()=="/nothink" || curr.trim()==`${localsettings.start_thinking_tag}${localsettings.stop_thinking_tag}`)
1514015141 {
1514115142 expandedhtml = `<span><button type="button" title="No Thoughts" class="btn btn-primary" style="font-size:12px;padding:2px 2px;" onclick="">No Thoughts</button><br></span>`;
0 commit comments