Skip to content

Commit

Permalink
fix editable colum xss
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanaelGT committed Nov 24, 2021
1 parent bd27b38 commit 29ccabc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions resources/views/assets/scripts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ function copyToClipboard(button) {
document.body.removeChild(el);
}
function htmlSpecialChars(string) {
const el = document.createElement('div');
el.innerText = string;
return el.innerHTML;
}
function isV2() {
return window.Alpine && window.Alpine.version && /^2\..+\..+$/.test(window.Alpine.version)
}
Expand Down
6 changes: 3 additions & 3 deletions resources/views/components/editable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
field: '{{ $field }}',
content: '{{ addslashes($row->{$field}) }}'
}">
<div x-text="content"
<div x-html="content"
style="border-bottom: dotted 1px; cursor: pointer"
x-show="!editable"
x-on:dblclick="editable = true"
Expand All @@ -22,12 +22,12 @@
<input
type="text"
x-on:dblclick="editable = true"
x-on:keydown.enter="sendEventInputChanged($event, id, field); editable = false; content = $event.target.value"
x-on:keydown.enter="sendEventInputChanged($event, id, field); editable = false; content = htmlSpecialChars($event.target.value)"
:class="{'cursor-pointer': !editable}"
class="{{ $theme->inputClass }} p-2"
x-ref="editable"
x-text="content"
:value="content">
:value="$root.firstElementChild.innerText">
</div>
</div>

Expand Down

0 comments on commit 29ccabc

Please sign in to comment.