This PR fixes issue #1300
Add URL Shortening for Cheat Sheets
Description
This PR adds automatic URL shortening functionality to make cheat sheets more accessible through memorable shortcuts. Instead of typing long URLs, users can now access cheat sheets using abbreviated paths.
For example:
/XSS.html→cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html/SSRF.html→cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html/SQLi.html→cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
Changes
- Added URL shortening logic to
Generate_Site_mkDocs.sh - Automatically generates shortcuts based on first letters of each word in filenames
- Creates clean URL .html version (
/XSS.html) - Adds HTML redirects with proper meta refresh tags
- Includes verification steps to ensure shortcuts are created correctly
Testing
After running Test shortcuts:
curl -L http://localhost:8000//CCS.html
curl -L http://localhost:8000/CCSP.html
curl -L http://localhost:8000/DOS.html
Benefits
- Easier to remember and share URLs
- Faster access to frequently used cheat sheets
- Maintains compatibility with existing full URLs
- Works with both clean URLs and .html extensions
Related Issues
Closes #1300
This is fantastic. I'm going to do a full review on it hopefully in the next day or two but I'm really excited about this. Thank you!
This is fantastic - thank you very very much!
Build is failing here @Farreeda
@szh can you review it again?
Sorry for the delay, I've been busy. I'll try to review it this week.
I'm ready to approve. Just one question - I see it generates both the clean urls like /xss and with the html suffix, such as /xss.html but the clean URL version doesn't actually get served. @Farreeda do you know if there's a way to get those to work? If not, we should probably not bother creating them.
The issue happens because the shortcut files (without .html) are being treated as raw files instead of actual HTML pages when accessed in a browser. The browser doesn't know how to interpret them, so it downloads them instead of rendering.
I'm ready to approve. Just one question - I see it generates both the clean urls like
/xssand with the html suffix, such as/xss.htmlbut the clean URL version doesn't actually get served. @Farreeda do you know if there's a way to get those to work? If not, we should probably not bother creating them.
The issue happens because the shortcut files (without .html) are being treated as raw files instead of actual HTML pages when accessed in a browser. The browser doesn't know how to interpret them, so it downloads them instead of rendering.
OK, so maybe we should just not create them? Or maybe there's some kind of config file (like a .htaccess file) that can instruct the server to serve them as html?
@Farreeda and @szh what do we need to do to release it? :)
Thank you for re-checking my PR @mackowski. The feature works with the /{shortcut}.html /{shortcut} alone is treated as a raw file and gets downloaded instead :/ We can merge it and open a new issue for this.
/{shortcut} alone is treated as a raw file and gets downloaded instead :/ We can merge it and open a new issue for this.
I'd prefer to fix it before we merge :)