Skip to content

Fix clipboard safe string regular expression#2153

Merged
KoalaSat merged 1 commit intoRoboSats:mainfrom
aftermath2:fix_android_clipboard_regex
Aug 8, 2025
Merged

Fix clipboard safe string regular expression#2153
KoalaSat merged 1 commit intoRoboSats:mainfrom
aftermath2:fix_android_clipboard_regex

Conversation

@aftermath2
Copy link
Contributor

What does this PR do?

Fixes #2152.

This PR updates the regular expression used to validate content pasted to the clipboard by removing extra backslashes and adding the double quote character (").

I haven't tested it though, not sure if characters should be escaped using two backslashes (\\[) or one (\[). I followed the android documentation https://developer.android.com/reference/kotlin/java/util/regex/Pattern

Before regex
After regex_quote

Checklist before merging

  • Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.

Copy link
Member

@KoalaSat KoalaSat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Please accept a tip for your work. Paste here a LN invoice for 30,000 sats with a long exploration date.

@KoalaSat KoalaSat merged commit 5caa60a into RoboSats:main Aug 8, 2025
@KoalaSat
Copy link
Member

KoalaSat commented Aug 8, 2025

It worked for me building form terminal but now Android Studio complains about the format 🤔 Not sure it this was really the issue

@KoalaSat
Copy link
Member

KoalaSat commented Aug 8, 2025

Saying that because I found that this https://github.com/RoboSats/robosats/pull/2154/files#diff-5726100c3de4fda01c1c98e342f00e99339efca15c82e26416c06e70e7f6fef7L112 was causing a lot of troubles and I removed it, which seemed to help

@aftermath2
Copy link
Contributor Author

aftermath2 commented Aug 9, 2025

It worked for me building form terminal but now Android Studio complains about the format 🤔 Not sure it this was really the issue

Saying that because I found that this https://github.com/RoboSats/robosats/pull/2154/files#diff-5726100c3de4fda01c1c98e342f00e99339efca15c82e26416c06e70e7f6fef7L112 was causing a lot of troubles and I removed it, which seemed to help

@KoalaSat It is related to the characters escaping, for Android Studio they might be escaped using two backslashes \\. We could try using

^[a-zA-Z0-9\\s_\\-.,:;!?()\\[\\]{}\\"]*$

like it was before but adding the double quotes character.

Note

This post explains it simply: Keep Your Regular Expression Escapes in Android

Let me know if I should open a new PR or if you try it in #2153

@aftermath2
Copy link
Contributor Author

I installed android studio and tried configuring it without much luck (not familiar with mobile dev). I don't get any linting errors or warnings neither. Is there a guide or steps to run the app in the emulator?

@KoalaSat
Copy link
Member

KoalaSat commented Aug 9, 2025

Is there a guide or steps to run the app in the emulator?

Not really it should be striagh forward. But it's true configuring your Java version and JDK to work with AD is pretty much a hell.

Let me know if I should open a new PR

Sounds good 👍

@aftermath2
Copy link
Contributor Author

PR with regex changes: #2155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: android: invalid content for clipboard

2 participants