Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix escaping in buffer selector #310

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

Here are the most notable changes in each release. For a more detailed list of changes, see the [Github Releases page](https://github.com/heyman/heynote/releases).

## 2.1.2
## 2.1.3

- Fix escaping issue in buffer selector (properly this time, hopefully)

## 2.1.2 (yanked)

- Fix issue where buffer name wasn't properly escaped in buffer selector

Expand Down
17 changes: 13 additions & 4 deletions src/components/BufferSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

const pathSep = window.heynote.buffer.pathSeparator

function escapeHTML(str) {
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}

export default {
props: {
headline: String,
Expand Down Expand Up @@ -106,8 +115,8 @@
this.items = Object.entries(this.buffers).map(([path, metadata]) => {
return {
"path": path,
"name": metadata?.name || path,
"folder": path.split(pathSep).slice(0, -1).join(pathSep),
"name": escapeHTML(metadata?.name || path),
"folder": escapeHTML(path.split(pathSep).slice(0, -1).join(pathSep)),
"scratch": path === SCRATCH_FILE_NAME,
}
})
Expand Down Expand Up @@ -263,8 +272,8 @@
@click="selectItem(item)"
ref="item"
>
<span class="name">{{ item.name }}</span>
<span class="path">{{ item.folder }}</span>
<span class="name" v-html="item.name" />
<span class="path" v-html="item.folder" />
<span :class="{'action-buttons':true, 'visible':actionButton > 0 && idx === selected}">
<button
v-if="actionButton > 0 && idx === selected"
Expand Down
Loading