Skip to content

Commit 8b87125

Browse files
committed
Merge branch 'dev'
2 parents bc3afe2 + a458e3e commit 8b87125

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

resources/js/components/matchmaking/ToolCard.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
class="relative flex-grow text-slate-500 text-[16px] leading-[22px] mb-2 overflow-hidden"
7272
style="height: auto"
7373
>
74-
<div v-html="tool.description" />
74+
<div v-html="formatMultiline(tool.description)" />
7575

7676
<div
7777
v-if="needShowMore"
@@ -121,6 +121,19 @@ export default {
121121
};
122122
},
123123
methods: {
124+
escapeHtml(value = '') {
125+
return String(value)
126+
.replace(/&/g, '&amp;')
127+
.replace(/</g, '&lt;')
128+
.replace(/>/g, '&gt;')
129+
.replace(/"/g, '&quot;')
130+
.replace(/'/g, '&#39;');
131+
},
132+
formatMultiline(value) {
133+
if (!value) return '';
134+
const normalized = String(value).replace(/\r\n?/g, '\n');
135+
return this.escapeHtml(normalized).replace(/\n/g, '<br>');
136+
},
124137
computeDescriptionHeight() {
125138
const containerEl = this.$refs.descriptionContainerRef;
126139
const descriptionEl = this.$refs.descriptionRef;

resources/js/components/matchmaking/ToolDetailCard.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<p
1818
v-if="isOrganisation"
1919
class="text-[#20262C] font-normal text-2xl p-0 mb-10"
20-
v-html="data.description"
20+
v-html="formatMultiline(data.description)"
2121
/>
2222

2323
<h3
@@ -72,7 +72,7 @@
7272
<p
7373
v-for="detail in item.list"
7474
class="p-0 pb-4 w-full"
75-
v-html="detail"
75+
v-html="formatMultiline(detail)"
7676
/>
7777
</div>
7878
</div>
@@ -113,7 +113,7 @@
113113
<p
114114
v-if="isOrganisation"
115115
class="p-0 text-slate-500 text-xl font-normal"
116-
v-html="data.description"
116+
v-html="formatMultiline(data.description)"
117117
/>
118118
</div>
119119
</div>
@@ -307,6 +307,20 @@ export default {
307307
}
308308
};
309309
310+
const escapeHtml = (value = '') =>
311+
String(value)
312+
.replace(/&/g, '&amp;')
313+
.replace(/</g, '&lt;')
314+
.replace(/>/g, '&gt;')
315+
.replace(/"/g, '&quot;')
316+
.replace(/'/g, '&#39;');
317+
318+
const formatMultiline = (value) => {
319+
if (!value) return '';
320+
const normalized = String(value).replace(/\r\n?/g, '\n');
321+
return escapeHtml(normalized).replace(/\n/g, '<br>');
322+
};
323+
310324
const orgData = computed(() => {
311325
const org = profileData.value;
312326
if (org.type !== 'organisation') return null;
@@ -510,6 +524,7 @@ export default {
510524
showAboutIndexes,
511525
handleToggleAbout,
512526
setDescriptionRef,
527+
formatMultiline,
513528
};
514529
},
515530
};

0 commit comments

Comments
 (0)