mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Escape prompt manager names
This commit is contained in:
@ -4,7 +4,7 @@ import { callPopup, event_types, eventSource, is_send_press, main_api, substitut
|
|||||||
import { is_group_generating } from "./group-chats.js";
|
import { is_group_generating } from "./group-chats.js";
|
||||||
import { TokenHandler } from "./openai.js";
|
import { TokenHandler } from "./openai.js";
|
||||||
import { power_user } from "./power-user.js";
|
import { power_user } from "./power-user.js";
|
||||||
import { debounce, waitUntilCondition } from "./utils.js";
|
import { debounce, waitUntilCondition, escapeHtml } from "./utils.js";
|
||||||
|
|
||||||
function debouncePromise(func, delay) {
|
function debouncePromise(func, delay) {
|
||||||
let timeoutId;
|
let timeoutId;
|
||||||
@ -1291,7 +1291,7 @@ PromptManagerModule.prototype.renderPromptManager = function () {
|
|||||||
const prompts = [...this.serviceSettings.prompts]
|
const prompts = [...this.serviceSettings.prompts]
|
||||||
.filter(prompt => prompt && !prompt?.system_prompt)
|
.filter(prompt => prompt && !prompt?.system_prompt)
|
||||||
.sort((promptA, promptB) => promptA.name.localeCompare(promptB.name))
|
.sort((promptA, promptB) => promptA.name.localeCompare(promptB.name))
|
||||||
.reduce((acc, prompt) => acc + `<option value="${prompt.identifier}">${prompt.name}</option>`, '');
|
.reduce((acc, prompt) => acc + `<option value="${prompt.identifier}">${escapeHtml(prompt.name)}</option>`, '');
|
||||||
|
|
||||||
const footerHtml = `
|
const footerHtml = `
|
||||||
<div class="${this.configuration.prefix}prompt_manager_footer">
|
<div class="${this.configuration.prefix}prompt_manager_footer">
|
||||||
@ -1440,13 +1440,14 @@ PromptManagerModule.prototype.renderPromptManagerListItems = function () {
|
|||||||
toggleSpanHtml = `<span class="fa-solid"></span>`;
|
toggleSpanHtml = `<span class="fa-solid"></span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const encodedName = escapeHtml(prompt.name);
|
||||||
listItemHtml += `
|
listItemHtml += `
|
||||||
<li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass}" data-pm-identifier="${prompt.identifier}">
|
<li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass}" data-pm-identifier="${prompt.identifier}">
|
||||||
<span class="${prefix}prompt_manager_prompt_name" data-pm-name="${prompt.name}">
|
<span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}">
|
||||||
${prompt.marker ? '<span class="fa-solid fa-thumb-tack" title="Marker"></span>' : ''}
|
${prompt.marker ? '<span class="fa-solid fa-thumb-tack" title="Marker"></span>' : ''}
|
||||||
${!prompt.marker && prompt.system_prompt ? '<span class="fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}
|
${!prompt.marker && prompt.system_prompt ? '<span class="fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}
|
||||||
${!prompt.marker && !prompt.system_prompt ? '<span class="fa-solid fa-user" title="User Prompt"></span>' : ''}
|
${!prompt.marker && !prompt.system_prompt ? '<span class="fa-solid fa-user" title="User Prompt"></span>' : ''}
|
||||||
${this.isPromptInspectionAllowed(prompt) ? `<a class="prompt-manager-inspect-action">${prompt.name}</a>` : prompt.name}
|
${this.isPromptInspectionAllowed(prompt) ? `<a class="prompt-manager-inspect-action">${encodedName}</a>` : encodedName}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<span class="prompt_manager_prompt_controls">
|
<span class="prompt_manager_prompt_controls">
|
||||||
|
@ -14,6 +14,10 @@ export const PAGINATION_TEMPLATE = '<%= rangeStart %>-<%= rangeEnd %> of <%= tot
|
|||||||
*/
|
*/
|
||||||
export const navigation_option = { none: 0, previous: 1, last: 2, };
|
export const navigation_option = { none: 0, previous: 1, last: 2, };
|
||||||
|
|
||||||
|
export function escapeHtml(str) {
|
||||||
|
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a value is unique in an array.
|
* Determines if a value is unique in an array.
|
||||||
* @param {any} value Current value.
|
* @param {any} value Current value.
|
||||||
|
Reference in New Issue
Block a user