Skip to content

Commit 7ba9c53

Browse files
committed
Escape javascript in jinja templates
1 parent e29288a commit 7ba9c53

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

β€Ž.github/templates/personalize_gemini_cell.py.j2β€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ copy_button_html = f'''
9393
const encodedText = '{persona_text_b64}';
9494
const byteChars = atob(encodedText);
9595
const byteNumbers = new Array(byteChars.length);
96-
for (let i = 0; i < byteChars.length; i++) {{
96+
for (let i = 0; i < byteChars.length; i++) {{{{
9797
byteNumbers[i] = byteChars.charCodeAt(i);
98-
}}
98+
}}}}
9999
const byteArray = new Uint8Array(byteNumbers);
100100
const decodedText = new TextDecoder('utf-8').decode(byteArray);
101101
102-
navigator.clipboard.writeText(decodedText).then(() => {{
102+
navigator.clipboard.writeText(decodedText).then(() => {{{{
103103
this.innerHTML = 'βœ… Copied to clipboard!';
104-
setTimeout(() => {{ this.innerHTML = 'πŸ“‹ Copy Persona Text'; }}, 2000);
105-
}}).catch(() => {{
104+
setTimeout(() => {{{{ this.innerHTML = 'πŸ“‹ Copy Persona Text'; }}}}, 2000);
105+
}}}}).catch(() => {{{{
106106
this.innerHTML = '❌ Copy failed - please copy manually from output above';
107-
setTimeout(() => {{ this.innerHTML = 'πŸ“‹ Copy Persona Text'; }}, 3000);
108-
}})
107+
setTimeout(() => {{{{ this.innerHTML = 'πŸ“‹ Copy Persona Text'; }}}}, 3000);
108+
}}}})
109109
">πŸ“‹ Copy Persona Text</button>
110110
'''
111111
display(HTML(copy_button_html))

β€Ž.github/templates/set_coding_rules_cell.py.j2β€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ copy_button_html = f'''
6363
const encodedText = '{ruleset_text_b64}';
6464
const byteChars = atob(encodedText);
6565
const byteNumbers = new Array(byteChars.length);
66-
for (let i = 0; i < byteChars.length; i++) {{
66+
for (let i = 0; i < byteChars.length; i++) {{{{
6767
byteNumbers[i] = byteChars.charCodeAt(i);
68-
}}
68+
}}}}
6969
const byteArray = new Uint8Array(byteNumbers);
7070
const decodedText = new TextDecoder('utf-8').decode(byteArray);
7171
72-
navigator.clipboard.writeText(decodedText).then(() => {{
72+
navigator.clipboard.writeText(decodedText).then(() => {{{{
7373
this.innerHTML = 'βœ… Copied to clipboard!';
74-
setTimeout(() => {{ this.innerHTML = 'πŸ“‹ Copy Rules Text'; }}, 2000);
75-
}}).catch(() => {{
74+
setTimeout(() => {{{{ this.innerHTML = 'πŸ“‹ Copy Rules Text'; }}}}, 2000);
75+
}}}}).catch(() => {{{{
7676
this.innerHTML = '❌ Copy failed - please copy manually from output above';
77-
setTimeout(() => {{ this.innerHTML = 'πŸ“‹ Copy Rules Text'; }}, 3000);
78-
}})
77+
setTimeout(() => {{{{ this.innerHTML = 'πŸ“‹ Copy Rules Text'; }}}}, 3000);
78+
}}}})
7979
">πŸ“‹ Copy Rules Text</button>
8080
'''
8181
display(HTML(copy_button_html))

0 commit comments

Comments
Β (0)