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
Open
fix: sanitize page titles and display names used as folder path segments in OneNote importer#503aaron-meyers wants to merge 2 commits intoobsidianmd:masterfrom
aaron-meyers wants to merge 2 commits intoobsidianmd:masterfrom
Conversation
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 😅 |
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! |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.