mirror of
https://github.com/RoboSats/robosats.git
synced 2025-08-16 08:17:15 +00:00
Revert unwanted changes
This commit is contained in:
@ -41,7 +41,8 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
|
|||||||
|
|
||||||
// Security patterns for input validation
|
// Security patterns for input validation
|
||||||
private val UUID_PATTERN = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", Pattern.CASE_INSENSITIVE)
|
private val UUID_PATTERN = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", Pattern.CASE_INSENSITIVE)
|
||||||
private val SAFE_STRING_PATTERN = Pattern.compile("^[a-zA-Z0-9\\s_\\-.,:;!?()\\[\\]{}\\"]*$")
|
private val SAFE_STRING_PATTERN = Pattern.compile("^[a-zA-Z0-9\\s_\\-.,:;!?()\\[\\]{}]*$")
|
||||||
|
|
||||||
// Maximum length for input strings
|
// Maximum length for input strings
|
||||||
private val MAX_INPUT_LENGTH = 1000
|
private val MAX_INPUT_LENGTH = 1000
|
||||||
|
|
||||||
@ -107,31 +108,18 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun copyToClipboard(message: String) {
|
fun copyToClipboard(message: String) {
|
||||||
// Validate input
|
|
||||||
if (!isValidInput(message, 10000)) { // Allow longer text for clipboard
|
|
||||||
Log.e(TAG, "Invalid input for copyToClipboard")
|
|
||||||
Toast.makeText(context, "Invalid content for clipboard", Toast.LENGTH_SHORT).show()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Limit clipboard content size for security
|
|
||||||
val truncatedMessage = if (message.length > 10000) {
|
|
||||||
message.substring(0, 10000) + "... (content truncated for security)"
|
|
||||||
} else {
|
|
||||||
message
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy to clipboard
|
// Copy to clipboard
|
||||||
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
|
||||||
val clip = android.content.ClipData.newPlainText("RoboSats Data", truncatedMessage)
|
val clip = android.content.ClipData.newPlainText("RoboSats Data", message)
|
||||||
clipboard.setPrimaryClip(clip)
|
clipboard.setPrimaryClip(clip)
|
||||||
|
|
||||||
// Show a toast notification
|
// Show a toast notification
|
||||||
Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
// Log the action (don't log the content for privacy)
|
// Log the action (don't log the content for privacy)
|
||||||
Log.d(TAG, "Text copied to clipboard (${truncatedMessage.length} chars)")
|
Log.d(TAG, "Text copied to clipboard (${message.length} chars)")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Error copying to clipboard", e)
|
Log.e(TAG, "Error copying to clipboard", e)
|
||||||
Toast.makeText(context, "Failed to copy to clipboard", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "Failed to copy to clipboard", Toast.LENGTH_SHORT).show()
|
||||||
|
Reference in New Issue
Block a user