Skip to content

Commit

Permalink
fix: enforce protocol in shortcut urls
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Jun 20, 2024
1 parent b28043c commit 2d05b92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-enforce-shortcut-url-protocol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Enforce shortcut URL protocol

We've fixed a bug where the protocol in shortcut URLs was not enforced. Now, the shortcut URL always starts `https://` if no protocol is provided by the user.

https://github.com/owncloud/web/issues/11063
https://github.com/owncloud/web/pull/11076
14 changes: 9 additions & 5 deletions packages/web-pkg/src/components/CreateShortcutModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,16 @@ export default defineComponent({
const isDropOpen = ref(false)
let markInstance = null
const dropItemUrl = computed(() => {
let url = unref(inputUrl).trim()
const getInputUrlWithProtocol = (input: string) => {
let url = input.trim()
if (isMaybeUrl(url)) {
return url
}
return `https://${url}`
}
const dropItemUrl = computed(() => {
return getInputUrlWithProtocol(unref(inputUrl))
})
const confirmButtonDisabled = computed(
Expand Down Expand Up @@ -327,7 +329,9 @@ export default defineComponent({
const onConfirm = async () => {
try {
// Omit possible xss code
const sanitizedUrl = DOMPurify.sanitize(unref(inputUrl), { USE_PROFILES: { html: true } })
const sanitizedUrl = DOMPurify.sanitize(getInputUrlWithProtocol(unref(inputUrl)), {
USE_PROFILES: { html: true }
})
const content = `[InternetShortcut]\nURL=${sanitizedUrl}`
const path = urlJoin(unref(currentFolder).path, `${unref(inputFilename)}.url`)
Expand Down

0 comments on commit 2d05b92

Please sign in to comment.