fix for names with quotes or apostrophes

This commit is contained in:
QuickMythril 2025-01-28 04:23:23 -05:00
parent 5a35fb0d07
commit da783c43ba
2 changed files with 11 additions and 2 deletions

View File

@ -1394,10 +1394,18 @@ const handleInviteMinter = async (minterName) => {
} }
} }
function escapeForHtmlAttribute(str) {
return str
.replace(/'/g, ''')
.replace(/"/g, '"');
}
const createInviteButtonHtml = (creator, cardIdentifier) => { const createInviteButtonHtml = (creator, cardIdentifier) => {
// Safely escape special chars so they won't break the HTML attribute
const safeCreator = escapeForHtmlAttribute(creator);
return ` return `
<div id="invite-button-container-${cardIdentifier}" style="margin-top: 1em;"> <div id="invite-button-container-${cardIdentifier}" style="margin-top: 1em;">
<button onclick="handleInviteMinter('${creator}')" <button onclick="handleInviteMinter('${safeCreator}')"
style="padding: 10px; background:rgb(0, 109, 76) ; color: white; border: dotted; border-color: white; cursor: pointer; border-radius: 5px;" style="padding: 10px; background:rgb(0, 109, 76) ; color: white; border: dotted; border-color: white; cursor: pointer; border-radius: 5px;"
onmouseover="this.style.backgroundColor='rgb(25, 47, 39) '" onmouseover="this.style.backgroundColor='rgb(25, 47, 39) '"
onmouseout="this.style.backgroundColor='rgba(7, 122, 101, 0.63) '" onmouseout="this.style.backgroundColor='rgba(7, 122, 101, 0.63) '"

View File

@ -331,7 +331,8 @@ const getNameInfo = async (name) => {
console.log('getNameInfo called') console.log('getNameInfo called')
console.log('name:', name) console.log('name:', name)
try { try {
const response = await fetch(`${baseUrl}/names/${name}`) // Encode the name for URL safety
const response = await fetch(`${baseUrl}/names/${encodeURIComponent(name)}`)
if (!response.ok) { if (!response.ok) {
console.warn(`Failed to fetch name info for: ${name}, status: ${response.status}`) console.warn(`Failed to fetch name info for: ${name}, status: ${response.status}`)