Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
c2202bdfef |
@@ -575,41 +575,6 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
debugPrint("Volume saved: $_volume");
|
debugPrint("Volume saved: $_volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if content appears to be keyboard smashing or repeated characters
|
|
||||||
bool _isLikelyKeyboardSmashing(String content) {
|
|
||||||
// Skip empty content
|
|
||||||
if (content.trim().isEmpty) return false;
|
|
||||||
|
|
||||||
// Check for repeated characters (like "wwwwwwww")
|
|
||||||
final repeatedCharPattern = RegExp(
|
|
||||||
r'(.)\1{4,}',
|
|
||||||
); // 5 or more repeated chars
|
|
||||||
if (repeatedCharPattern.hasMatch(content)) {
|
|
||||||
// But allow if it's a legitimate pattern like base64
|
|
||||||
if (RegExp(r'^[A-Za-z0-9+/=]+$').hasMatch(content)) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for alternating characters (like "asdfasdf")
|
|
||||||
final alternatingPattern = RegExp(r'(.)(.)\1\2{2,}');
|
|
||||||
if (alternatingPattern.hasMatch(content)) return true;
|
|
||||||
|
|
||||||
// Check for common keyboard smashing patterns
|
|
||||||
final commonPatterns = [
|
|
||||||
r'[qwerty]{5,}', // Common keyboard rows
|
|
||||||
r'[asdf]{5,}',
|
|
||||||
r'[zxcv]{5,}',
|
|
||||||
r'[1234]{5,}',
|
|
||||||
r'[wasd]{5,}', // Common gaming keys
|
|
||||||
];
|
|
||||||
|
|
||||||
for (final pattern in commonPatterns) {
|
|
||||||
if (RegExp(pattern, caseSensitive: false).hasMatch(content)) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _saveData() async {
|
Future<void> _saveData() async {
|
||||||
String previousEntry = _previousEntryController.text;
|
String previousEntry = _previousEntryController.text;
|
||||||
String currentEntry = _currentEntryController.text;
|
String currentEntry = _currentEntryController.text;
|
||||||
@@ -619,14 +584,8 @@ class MainPageState extends State<MainPage> with WindowListener {
|
|||||||
|
|
||||||
// Handle current entry
|
// Handle current entry
|
||||||
if (currentEntry.isNotEmpty) {
|
if (currentEntry.isNotEmpty) {
|
||||||
// Skip saving if it looks like keyboard smashing
|
await createNote(currentEntry);
|
||||||
if (!_isLikelyKeyboardSmashing(currentEntry)) {
|
_currentEntryController.clear(); // Clear the input field after saving
|
||||||
await createNote(currentEntry);
|
|
||||||
_currentEntryController.clear(); // Clear the input field after saving
|
|
||||||
} else {
|
|
||||||
debugPrint("Skipping save of likely keyboard smashing: $currentEntry");
|
|
||||||
_currentEntryController.clear(); // Still clear the input
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle scratch pad
|
// Handle scratch pad
|
||||||
|
Reference in New Issue
Block a user