Skip to content

Commit

Permalink
Use own escapeHtml instead of prototypejs
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Feb 21, 2024
1 parent 0011adb commit 09cb85c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/javascript/src/classes/browser_view.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PreloadContainer from 'src/classes/preload_container'
import { escapeHtml } from 'src/utils/dom'
import { removeImageElement } from 'src/utils/image'
import { numberToHumanSize } from 'src/utils/math'
import FrameEditor from './frame_editor'
Expand Down Expand Up @@ -681,7 +682,7 @@ export default class BrowserView
div = html.subst(
sequence: sequence
pool_id: pool_id
desc: pool_title.escapeHTML()).createElement()
desc: escapeHtml(pool_title)).createElement()
div.post_id = post.id
div.pool_id = pool_id
pool_info.appendChild div
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/src/classes/inline_image.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { escapeHtml } from 'src/utils/dom'

export default class InlineImage
constructor: ->
@mouse_down = null
Expand Down Expand Up @@ -54,7 +56,7 @@ export default class InlineImage
while idx < data.images.length
# html_id looks like "inline-123-456". Mark the button for each individual image as "inline-123-456-2".
button_id = data.html_id + '-' + idx
text = data.images[idx].description.escapeHTML()
text = escapeHtml(data.images[idx].description)
if text == ''
text = '#' + idx + 1
ui_html += '<a href=\'#\' id=\'' + button_id + '\' class=\'select-image\' onclick=\'InlineImage.show_image_no("' + data.html_id + '", ' + idx + '); return false;\'>' + text + '</a>'
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/src/utils/dom.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export hideEl = (el) -> el.style.display = 'none'

export showEl = (el) -> el.style.display = ''

export escapeHtml = (str) -> str.replace(/[&<>"']/g, (str) => ({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
})[str])

0 comments on commit 09cb85c

Please sign in to comment.