import: apply fixPgpMessage to text for import from clipboard
This commit is contained in:
@@ -117,7 +117,7 @@ public class PgpHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPgpContent(@NonNull CharSequence input) {
|
public static String getPgpMessageContent(@NonNull CharSequence input) {
|
||||||
Log.dEscaped(Constants.TAG, "input: " + input);
|
Log.dEscaped(Constants.TAG, "input: " + input);
|
||||||
|
|
||||||
Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(input);
|
Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(input);
|
||||||
@@ -141,4 +141,18 @@ public class PgpHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPgpKeyContent(@NonNull CharSequence input) {
|
||||||
|
Log.dEscaped(Constants.TAG, "input: " + input);
|
||||||
|
|
||||||
|
Matcher matcher = PgpHelper.PGP_PUBLIC_KEY.matcher(input);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
String text = matcher.group(1);
|
||||||
|
text = fixPgpMessage(text);
|
||||||
|
|
||||||
|
Log.dEscaped(Constants.TAG, "input fixed: " + text);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public class DecryptActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clean up ascii armored message, fixing newlines and stuff
|
// clean up ascii armored message, fixing newlines and stuff
|
||||||
String cleanedText = PgpHelper.getPgpContent(text);
|
String cleanedText = PgpHelper.getPgpMessageContent(text);
|
||||||
if (cleanedText == null) {
|
if (cleanedText == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import android.view.ViewGroup;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||||
import org.sufficientlysecure.keychain.util.FileHelper;
|
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||||
|
|
||||||
public class ImportKeysFileFragment extends Fragment {
|
public class ImportKeysFileFragment extends Fragment {
|
||||||
@@ -78,12 +81,16 @@ public class ImportKeysFileFragment extends Fragment {
|
|||||||
String sendText = "";
|
String sendText = "";
|
||||||
if (clipboardText != null) {
|
if (clipboardText != null) {
|
||||||
sendText = clipboardText.toString();
|
sendText = clipboardText.toString();
|
||||||
|
sendText = PgpHelper.getPgpKeyContent(sendText);
|
||||||
|
if (sendText == null) {
|
||||||
|
Notify.create(mImportActivity, "Bad data!", Style.ERROR).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(sendText.getBytes(), null));
|
mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(sendText.getBytes(), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user