When creating a new lesson using `scripts/new_lesson.py` (either interactively or via batch mode), if the user or agent supplies a title with special characters…
When creating a new lesson using scripts/new_lesson.py (either interactively or via batch mode), if the user or agent supplies a title with special characters, slashes (/, \), emojis, or Windows reserved names, the slugify logic crashes, generates invalid file paths, or attempts to write to reserved devices (like CON or PRN on Windows). This disrupts the creation workflow on Windows and WSL systems.
/) and backslashes (\) were not explicitly replaced first, potentially resulting in nested directories or path traversal if not fully cleaned._slugify returned an empty string "", leading to writing a hidden file .md directly to the lessons/ root, which triggers crashes or invalid path errors.CON, PRN, AUX, NUL, etc.), Windows prevents creating the file or redirects the file write to physical devices/null, resulting in permission errors or environment crashes.Hardened the _slugify logic in scripts/new_lesson.py using standard library libraries and safeguards:
unicodedata.normalize('NFKD', title) to strip accents and normalize letters./ and \ with - explicitly before regex stripping.lesson-YYYYMMDD-HHMMSS.safe- prefix if the slug matches any Windows reserved name (e.g. con becomes safe-con).echo "Lesson: slugify windows path sanitation"
wc -l lessons/contrib/slugify-windows-path-sanitation.mdExpected Output:
Lesson: slugify windows path sanitation
# (line count)