Skip to content
Open
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
2 changes: 1 addition & 1 deletion client/views/Note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const isDraftModalVisible = ref(false);
const isNewNote = computed(() => !props.title);
const loadingIndicator = ref();
const note = ref({});
const reservedFilenameCharacters = /[<>:"/\\|?*]/;
const reservedFilenameCharacters = /[<>:"\\|?*]/;
const router = useRouter();
const newTitle = ref();
const toast = useToast();
Expand Down
2 changes: 1 addition & 1 deletion server/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def camel_case(snake_case_str: str) -> str:
def is_valid_filename(value):
"""Raise ValueError if the declared string contains any of the following
characters: <>:"/\\|?*"""
invalid_chars = r'<>:"/\|?*'
invalid_chars = r'<>:"\|?*'
if any(invalid_char in value for invalid_char in invalid_chars):
raise ValueError(
"title cannot include any of the following characters: "
Expand Down
4 changes: 2 additions & 2 deletions server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@router.get("/login", include_in_schema=False)
@router.get("/search", include_in_schema=False)
@router.get("/new", include_in_schema=False)
@router.get("/note/{title}", include_in_schema=False)
@router.get("/note/{title:path}", include_in_schema=False)
def root(title: str = ""):
with open("client/dist/index.html", "r", encoding="utf-8") as f:
html = f.read()
Expand Down Expand Up @@ -61,7 +61,7 @@ def token(data: Login):
# region Notes
# Get Note
@router.get(
"/api/notes/{title}",
"/api/notes/{title:path}",
dependencies=auth_deps,
response_model=Note,
)
Expand Down
6 changes: 4 additions & 2 deletions server/notes/file_system/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ def _add_note_to_index(
def _list_all_note_filenames(self) -> List[str]:
"""Return a list of all note filenames."""
return [
os.path.split(filepath)[1]
os.path.relpath(filepath, self.storage_path)
for filepath in glob.glob(
os.path.join(self.storage_path, "*" + MARKDOWN_EXT)
os.path.join(self.storage_path, "**/*" + MARKDOWN_EXT), recursive = True
)
]

Expand Down Expand Up @@ -390,5 +390,7 @@ def _read_file(filepath: str):
@staticmethod
def _write_file(filepath: str, content: str, overwrite: bool = False):
logger.debug(f"Writing to '{filepath}'")
directory = os.path.dirname(filepath)
os.makedirs(directory, exist_ok = True)
with open(filepath, "w" if overwrite else "x") as f:
f.write(content)