-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsafe characters end up in documentation filenames. #699
Comments
Well, right now GitHub Pages fails to load any of my documentation unless I manually remove the offending files, leaving broken links in my wake. So I’m somewhat impatient to see it fixed. I’ve read the other threads you mentioned @jpsim, and I have a possible solution with them all in mind. I’ll explain it here for posterity in a minute and then try my hand at a pull request, but I realize this one will probably require a lot of review. |
Design Considerations: 1. Sanitized filenames should only accessible with a configuration option for now. Because... 2. Sanitization should be applied solely to path components generated from swift code. Manually defined path components such as custom categories should remain in the developer’s direct control. 3. An existing standard should be used, in order to efficiently deal with all related problems at once, including those still unnoticed. CGI.escape() is designed precicely for this purpose and it is conveniently located in the Ruby Standard Library. 4. The file name itself must be sanitized, not just the links that point to it. The issue is not just about referencing the file; the ability to save and host the documentation is at risk. It has been asked if this is a Windows‐only problem, but this is not the case. As noted in my earlier comment, GitHub Pages crashes when it tries to import my Jazzy‐generated documentation and yields a site‐wide 404. The example I have repeatedly used, 5. Mere percent encoding is insufficient. As @mbogh noticed, this breaks the links. Here is why: 6. Normalization form NFC sometimes reduces the number of offending characters in a string. A single composed character will be escaped instead of several combining characters in a row. This makes a minor improvement to the readability of the resulting filenames. |
Moving the branch for #699 into the main repository for easier testing.
The configuration option
Any other flags you normally use (such as |
Swift function names allow (and require in the case of the colon) characters that are dangerous to use in filenames and URLs. Jazzy naïvely uses these function names when it assigns filenames to the HTML it outputs. This results in problems when one attempts to host the documentation.
For example, the following code is valid Swift:
But the resulting file is
/(_:_:).html
, which is a disaster waiting to happen.Test it in no time by pasting the following terminal commands. (Make sure there isn’t some other “Project” folder in the current directory first!)
When the documentation opens, click on the link to the function in the top left... and see the ensuing chaos.
The text was updated successfully, but these errors were encountered: