diff --git a/frontend/package.json b/frontend/package.json index 98cd51a3..61ebcf81 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -30,6 +30,7 @@ "chart.js": "^4.4.1", "codemirror": "^6.0.1", "dayjs": "^1.11.6", + "dompurify": "^3.2.6", "feather-icons": "^4.28.0", "frappe-ui": "0.1.173", "highlight.js": "^11.11.1", diff --git a/frontend/src/components/Modals/EditProfile.vue b/frontend/src/components/Modals/EditProfile.vue index d335b39f..144878ae 100644 --- a/frontend/src/components/Modals/EditProfile.vue +++ b/frontend/src/components/Modals/EditProfile.vue @@ -97,7 +97,8 @@ import { } from 'frappe-ui' import { reactive, watch } from 'vue' import { FileText, X } from 'lucide-vue-next' -import { getFileSize } from '@/utils' +import { getFileSize, decodeEntities } from '@/utils' +import DOMPurify from 'dompurify' const reloadProfile = defineModel('reloadProfile') @@ -147,6 +148,22 @@ const updateProfile = createResource({ }) const saveProfile = (close) => { + profile.bio = DOMPurify.sanitize(decodeEntities(profile.bio), { + ALLOWED_TAGS: [ + 'b', + 'i', + 'em', + 'strong', + 'a', + 'p', + 'br', + 'ul', + 'ol', + 'li', + 'img', + ], + ALLOWED_ATTR: ['href', 'target', 'src'], + }) updateProfile.submit( {}, { diff --git a/frontend/src/pages/ProfileAbout.vue b/frontend/src/pages/ProfileAbout.vue index 6ef662dc..47477d38 100644 --- a/frontend/src/pages/ProfileAbout.vue +++ b/frontend/src/pages/ProfileAbout.vue @@ -5,7 +5,24 @@
@@ -101,6 +118,8 @@ import { inject } from 'vue' import { createResource, Popover, Button } from 'frappe-ui' import { X, LinkedinIcon, Twitter } from 'lucide-vue-next' import { sessionStore } from '@/stores/session' +import { decodeEntities } from '@/utils' +import DOMPurify from 'dompurify' const dayjs = inject('$dayjs') const { branding } = sessionStore() diff --git a/frontend/src/pages/QuizForm.vue b/frontend/src/pages/QuizForm.vue index a6f97ffd..dc3cf2ce 100644 --- a/frontend/src/pages/QuizForm.vue +++ b/frontend/src/pages/QuizForm.vue @@ -119,7 +119,7 @@
diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index a004f28c..56ef3a59 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -799,3 +799,9 @@ export const blockQuotesClick = () => { }) }) } + +export const decodeEntities = (encodedString) => { + const textarea = document.createElement('textarea') + textarea.innerHTML = encodedString + return textarea.value +} diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 98a6ab72..692b756e 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1975,7 +1975,6 @@ def get_program_details(program_name): "member_count", "course_count", "published", - "allow_self_enrollment", "enforce_course_order", ], as_dict=1,