obsidian-linter icon indicating copy to clipboard operation
obsidian-linter copied to clipboard

Bug: Titles with special characters not getting escaped in aliases

Open tbdcit opened this issue 2 years ago • 2 comments

Describe the Bug

Titles containing the character ' are not escaped when they are added to the list of aliases under the "yaml title alias plugin".

How to Reproduce

Create a new vault with just this plugin installed. Enable the options:

  • escapes colons with space ....
  • yaml title aliases

Example to reproduce issue with:

# It's strange

or

---
aliases:
 - "It's strange"
---
# It's strange

Expected Behavior

  • the title is escaped before being added to the list of aliases
  • if the escaped version of the title already exists in the aliases it does get added again

In both cases above the output should be

---
aliases:
 - "It's strange"
---
# It's strange

Actual behaviour

# It's strange

becomes

---
aliases:
  - It's strange
---
# It's strange

and

---
aliases:
 - "It's strange"
---
# It's strange

becomes

---
aliases:
  - It's strange
  - "It's strange"
---
# It's strange

Device

  • [x] Desktop
  • [ ] Mobile

tbdcit avatar Oct 03 '22 22:10 tbdcit

Thanks for reporting the issue! I will see about taking a look at this for the next release. It looks like I am not checking for its existence as an escaped and un-escaped value in the list of existing values which makes it think it is different, but maybe it is not escaping at all.

pjkaufman avatar Oct 06 '22 15:10 pjkaufman

I will also note that there are two rules being mentioned here. They run separately and do not affect each other directly. This means that the issue may be in the title alias not escaping the value.

pjkaufman avatar Oct 06 '22 15:10 pjkaufman

I thought I fixed this in prep for the release, but I will check again soon. I plan to do a release soon, but have been quite busy.

pjkaufman avatar Oct 24 '22 18:10 pjkaufman

I found the issue here and now have a fix pretty much ready. I just need to verify it works for the two scenarios described here and then push it on up. This affected 2 rules and should not be too big a change. It just means that the custom escaping logic will be used in all places instead of the js-yaml one. This means that some things may not behave the same with escaping yaml, but it should be more consistent.

pjkaufman avatar Oct 26 '22 00:10 pjkaufman

This should be fixed with the next release. Please let us know if the issue persists.

pjkaufman avatar Oct 26 '22 01:10 pjkaufman