-
-
Notifications
You must be signed in to change notification settings - Fork 0
Sanitize form inputs: trim whitespace and escape HTML (client + server-side) #13
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
Conversation
Co-authored-by: quamilek <695791+quamilek@users.noreply.github.com>
Co-authored-by: quamilek <695791+quamilek@users.noreply.github.com>
Co-authored-by: quamilek <695791+quamilek@users.noreply.github.com>
|
@copilot use |
1 similar comment
|
@copilot use |
quamilek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot use | safe tag in all variables provided by user.
Use also Markup from flask framework
- Changed sanitize_text_input() to return Markup objects instead of strings - Markup objects prevent double-escaping by Jinja2 - Added | safe filter in qso_list.html for callsign and filename variables - Import Markup from markupsafe instead of escape function Co-authored-by: quamilek <695791+quamilek@users.noreply.github.com>
Done. Updated Commit: 9121ee6 |
- Apply sanitize_text_input() to file.filename before passing to template - Ensures filename is also trimmed and HTML-escaped like other user inputs - Add test case for filename sanitization with HTML characters - All 23 tests pass with 0 linting errors Co-authored-by: quamilek <695791+quamilek@users.noreply.github.com>
Completed. All user-provided variables now use Markup and | safe filter. Added sanitization for the Commit: 9f0358c
Completed. All user-provided variables now use Markup and | safe filter. Added sanitization for the Commit: 9f0358c |
|
@copilot Add automatic strip string to remove white characters on start and end call and locator field in form. Do it on the browser side in java script code |
- Add JavaScript in main.html template to trim callsign and locator fields - Trim on blur event (when user leaves field) for immediate feedback - Trim on form submit as final safety check before sending to server - Complements existing server-side sanitization for better UX - Prevents user frustration from trailing spaces added by mobile keyboards Co-authored-by: quamilek <695791+quamilek@users.noreply.github.com>
Done. Added JavaScript to automatically trim whitespace from callsign and locator fields on the browser side. The trimming happens:
This complements the existing server-side sanitization and provides better UX, especially for mobile users. Commit: f616ade |
Form Input Sanitization - Complete ✅
Implementation Summary:
Created
sanitize_text_input()function inqsomap/upload.pythat:Markup.escape()to prevent XSSMarkupobjects (not strings) to prevent double-escapingApplied sanitization to ALL user-provided text inputs:
Template changes:
| safefilter to{{ callsign }}and{{ filename }}in qso_list.htmlClient-Side Enhancement:
Added JavaScript to automatically trim whitespace from form fields for better user experience:
Testing Results:
✅ All 14 input sanitization tests pass (including new filename test)
✅ All 9 existing Flask tests pass
✅ All 23 tests pass with 0 linting errors
✅ CodeQL security scan: 0 alerts
✅ Code review: all feedback addressed
Security:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.