#!/usr/bin/env python3 """ Quick manual test to verify the filename validation fix. Tests the exact case from the bug report. """ import sys sys.path.insert(0, 'src') from utils.input_validation import validate_filename_safe, PathTraversalError print("\n" + "="*70) print("FILENAME VALIDATION FIX - MANUAL TEST") print("="*70 + "\n") # Bug report case bug_report_filename = "This Weird FPV Drone only takes one kind of Battery... Rekon 35 V2.m4a" print(f"Testing bug report filename:") print(f" '{bug_report_filename}'") print() try: result = validate_filename_safe(bug_report_filename) print(f"✅ SUCCESS: Filename accepted!") print(f" Returned: '{result}'") except PathTraversalError as e: print(f"❌ FAILED: {e}") sys.exit(1) except Exception as e: print(f"❌ ERROR: {e}") sys.exit(1) print() # Test that security still works print("Verifying security (path traversal should still be blocked):") dangerous_filenames = [ "../../../etc/passwd", "../../secrets.txt", "dir/file.m4a", ] for dangerous in dangerous_filenames: try: validate_filename_safe(dangerous) print(f"❌ SECURITY ISSUE: '{dangerous}' was accepted (should be blocked!)") sys.exit(1) except PathTraversalError: print(f"✅ '{dangerous}' correctly blocked") print() print("="*70) print("ALL TESTS PASSED! ✅") print("="*70) print() print("The fix is working correctly:") print(" ✓ Filenames with ellipsis (...) are now accepted") print(" ✓ Path traversal attacks are still blocked") print()