Skip to content
Snippets Groups Projects
Commit 0562635b authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

drop broken and insecure custom v-highlightjs attr, fixes #4437

Closes #4437

Merge request studip/studip!3227
parent 90bac9f4
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
> >
<template #content> <template #content>
<pre v-show="currentContent !== ''" v-highlightjs="currentContent"><code ref="code" :class="[currentLang]"></code></pre> <pre v-show="currentContent !== ''"><code v-html="highlightContent" class="hljs"></code></pre>
<div v-show="currentLang !== ''" class="code-lang"> <div v-show="currentLang !== ''" class="code-lang">
<span>{{ currentLang }}</span> <span>{{ currentLang }}</span>
</div> </div>
...@@ -63,28 +63,9 @@ export default { ...@@ -63,28 +63,9 @@ export default {
lang() { lang() {
return this.block?.attributes?.payload?.lang; return this.block?.attributes?.payload?.lang;
}, },
}, highlightContent() {
directives: { let language = this.currentLang !== '' ? [this.currentLang] : null;
highlightjs: { return hljs.highlightAuto(this.currentContent, language).value;
deep: true,
bind(el, binding) {
let targets = el.querySelectorAll('code');
targets.forEach((target) => {
if (binding.value) {
target.innerHTML = binding.value;
}
hljs.highlightBlock(target);
});
},
componentUpdated(el, binding) {
let targets = el.querySelectorAll('code');
targets.forEach((target) => {
if (binding.value) {
target.innerHTML = binding.value;
hljs.highlightBlock(target);
}
});
},
}, },
}, },
mounted() { mounted() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment