CheatSheetSeries icon indicating copy to clipboard operation
CheatSheetSeries copied to clipboard

This PR fixes issue #1300

Open Farreeda opened this issue 10 months ago • 11 comments

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.htmlcheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
  • /SSRF.htmlcheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
  • /SQLi.htmlcheatsheets/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

Farreeda avatar Jan 30 '25 18:01 Farreeda

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!

szh avatar Feb 03 '25 14:02 szh

This is fantastic - thank you very very much!

jmanico avatar Feb 05 '25 08:02 jmanico

Build is failing here @Farreeda

mackowski avatar Feb 05 '25 13:02 mackowski

@szh can you review it again?

mackowski avatar Feb 12 '25 13:02 mackowski

Sorry for the delay, I've been busy. I'll try to review it this week.

szh avatar Feb 17 '25 09:02 szh

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.

szh avatar Feb 19 '25 19:02 szh

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 /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.

Farreeda avatar Mar 01 '25 11:03 Farreeda

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?

szh avatar Mar 03 '25 13:03 szh

@Farreeda and @szh what do we need to do to release it? :)

mackowski avatar May 19 '25 11:05 mackowski

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.

Farreeda avatar May 19 '25 11:05 Farreeda

/{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 :)

szh avatar May 19 '25 13:05 szh