Skip to content

fix: sanitize page titles and display names used as folder path segments in OneNote importer#503

Open
aaron-meyers wants to merge 2 commits intoobsidianmd:masterfrom
aaron-meyers:master
Open

fix: sanitize page titles and display names used as folder path segments in OneNote importer#503
aaron-meyers wants to merge 2 commits intoobsidianmd:masterfrom
aaron-meyers:master

Conversation

@aaron-meyers
Copy link
Copy Markdown

OneNote import was not sanitizing page titles and section/group names when creating folders which could result in unexpected subfolder levels, names with leading or trailing whitespace etc.

Tested locally.

@aaron-meyers
Copy link
Copy Markdown
Author

@tgrosinger any concerns with this change? I have some other improvement ideas for the OneNote importer in mind but wanted to get this small fix in before doing anything too drastic 😅

@tgrosinger
Copy link
Copy Markdown
Contributor

Looks good to me overall, except I would prefer if we could avoid the assertions where possible. Perhaps add a fallback instead?

sanitizeFileName(notebook.displayName ?? 'Untitled Notebook')
sanitizeFileName(page.title ?? 'Untitled')
sanitizeFileName(sectionGroup.displayName ?? 'Untitled')

Thank you!

@aaron-meyers
Copy link
Copy Markdown
Author

Done. The code appeared to be assuming these were non-empty/non-null already but added the fallback for good measure (this might actually fix a bug because I think it is possible for OneNote pages at least to have an empty title). I used || so that empty string falls back as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants