mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2026-01-20 07:03:02 -05:00
Potential fix for code scanning alert no. 6: Incomplete string escaping or encoding
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -597,8 +597,11 @@ export async function init(
|
|||||||
if (fs.existsSync(constantsPath)) {
|
if (fs.existsSync(constantsPath)) {
|
||||||
let constantsContent = fs.readFileSync(constantsPath, 'utf8');
|
let constantsContent = fs.readFileSync(constantsPath, 'utf8');
|
||||||
|
|
||||||
// Helper function to escape single quotes in strings
|
// Helper function to escape backslashes and single quotes in strings
|
||||||
const escapeString = (str) => str.replace(/'/g, "\\'");
|
const escapeString = (str) =>
|
||||||
|
String(str)
|
||||||
|
.replace(/\\/g, '\\\\') // escape all backslashes
|
||||||
|
.replace(/'/g, "\\'"); // then escape single quotes
|
||||||
|
|
||||||
// Helper function to safely replace constants with validation
|
// Helper function to safely replace constants with validation
|
||||||
const safeReplace = (content, pattern, replacement, constantName) => {
|
const safeReplace = (content, pattern, replacement, constantName) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user