Mime type consistency
This commit is contained in:
@@ -44,13 +44,14 @@ public final class Constants {
|
||||
|
||||
public static final String CLIPBOARD_LABEL = "Keychain";
|
||||
|
||||
// as defined in http://tools.ietf.org/html/rfc3156, section 7
|
||||
public static final String NFC_MIME = "application/pgp-keys";
|
||||
|
||||
// as defined in http://tools.ietf.org/html/rfc3156
|
||||
// we don't use application/pgp-encrypted as it only holds the version number
|
||||
public static final String ENCRYPTED_FILES_MIME = "application/octet-stream";
|
||||
public static final String ENCRYPTED_TEXT_MIME = "text/plain";
|
||||
public static final String MIME_TYPE_KEYS = "application/pgp-keys";
|
||||
// NOTE: don't use application/pgp-encrypted It only holds the version number!
|
||||
public static final String MIME_TYPE_ENCRYPTED = "application/octet-stream";
|
||||
// NOTE: Non-standard alternative, better use this, because application/octet-stream is too unspecific!
|
||||
// also see https://tools.ietf.org/html/draft-bray-pgp-message-00
|
||||
public static final String MIME_TYPE_ENCRYPTED_ALTERNATE = "application/pgp-message";
|
||||
public static final String MIME_TYPE_TEXT = "text/plain";
|
||||
|
||||
public static final String FILE_EXTENSION_PGP_MAIN = ".pgp";
|
||||
public static final String FILE_EXTENSION_PGP_ALTERNATE = ".gpg";
|
||||
|
||||
@@ -417,10 +417,10 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
|
||||
// special treatment to detect pgp mime types
|
||||
if (matchesPrefix(firstBytes, "-----BEGIN PGP PUBLIC KEY BLOCK-----")
|
||||
|| matchesPrefix(firstBytes, "-----BEGIN PGP PRIVATE KEY BLOCK-----")) {
|
||||
mimeType = "application/pgp-keys";
|
||||
mimeType = Constants.MIME_TYPE_KEYS;
|
||||
} else if (matchesPrefix(firstBytes, "-----BEGIN PGP MESSAGE-----")) {
|
||||
// this is NOT pgp/encrypted, see RFC 3156!
|
||||
mimeType = "application/pgp-message";
|
||||
// this is NOT application/pgp-encrypted, see RFC 3156!
|
||||
mimeType = Constants.MIME_TYPE_ENCRYPTED_ALTERNATE;
|
||||
}
|
||||
|
||||
log.add(LogType.MSG_DC_CLEAR_META_MIME, indent + 1, mimeType);
|
||||
|
||||
@@ -431,14 +431,14 @@ public class BackupCodeFragment extends CryptoOperationFragment<ExportKeyringPar
|
||||
+ (mExportSecret ? Constants.FILE_EXTENSION_PGP_MAIN : ".pub" + Constants.FILE_EXTENSION_PGP_MAIN);
|
||||
|
||||
if (mCachedBackupUri == null) {
|
||||
mCachedBackupUri = TemporaryFileProvider.createFile(activity, filename, Constants.ENCRYPTED_FILES_MIME);
|
||||
mCachedBackupUri = TemporaryFileProvider.createFile(activity, filename, Constants.MIME_TYPE_ENCRYPTED_ALTERNATE);
|
||||
cryptoOperation();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mShareNotSave) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("application/octet-stream");
|
||||
intent.setType(Constants.MIME_TYPE_ENCRYPTED_ALTERNATE);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, mCachedBackupUri);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
@@ -455,7 +455,7 @@ public class BackupCodeFragment extends CryptoOperationFragment<ExportKeyringPar
|
||||
|
||||
// for kitkat and above, we have the document api
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
FileHelper.saveDocument(this, "application/octet-stream", filename, REQUEST_SAVE);
|
||||
FileHelper.saveDocument(this, Constants.MIME_TYPE_ENCRYPTED_ALTERNATE, filename, REQUEST_SAVE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ public class DecryptListFragment
|
||||
if (ClipDescription.compareMimeTypes(type, "text/plain")) {
|
||||
// noinspection deprecation, this should be called from Context, but not available in minSdk
|
||||
icon = getResources().getDrawable(R.drawable.ic_chat_black_24dp);
|
||||
} else if (ClipDescription.compareMimeTypes(type, "application/pgp-keys")) {
|
||||
} else if (ClipDescription.compareMimeTypes(type, Constants.MIME_TYPE_KEYS)) {
|
||||
// noinspection deprecation, this should be called from Context, but not available in minSdk
|
||||
icon = getResources().getDrawable(R.drawable.ic_key_plus_grey600_24dp);
|
||||
} else if (ClipDescription.compareMimeTypes(type, "image/*")) {
|
||||
@@ -534,7 +534,7 @@ public class DecryptListFragment
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(outputUri, metadata.getMimeType());
|
||||
|
||||
if (!forceChooser && "application/pgp-keys".equals(metadata.getMimeType())) {
|
||||
if (!forceChooser && Constants.MIME_TYPE_KEYS.equals(metadata.getMimeType())) {
|
||||
// bind Intent to this OpenKeychain, don't allow other apps to intercept here!
|
||||
intent.setPackage(getActivity().getPackageName());
|
||||
}
|
||||
@@ -777,7 +777,7 @@ public class DecryptListFragment
|
||||
filename = getString(R.string.filename_unknown);
|
||||
} else if ( ! TextUtils.isEmpty(metadata.getFilename())) {
|
||||
filename = metadata.getFilename();
|
||||
} else if (ClipDescription.compareMimeTypes(metadata.getMimeType(), "application/pgp-keys")) {
|
||||
} else if (ClipDescription.compareMimeTypes(metadata.getMimeType(), Constants.MIME_TYPE_KEYS)) {
|
||||
filename = getString(R.string.filename_keys);
|
||||
} else if (ClipDescription.compareMimeTypes(metadata.getMimeType(), "text/plain")) {
|
||||
filename = getString(R.string.filename_unknown_text);
|
||||
|
||||
@@ -608,7 +608,7 @@ public class EncryptFilesFragment
|
||||
sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, mOutputUris);
|
||||
}
|
||||
sendIntent.setType(Constants.ENCRYPTED_FILES_MIME);
|
||||
sendIntent.setType(Constants.MIME_TYPE_ENCRYPTED_ALTERNATE);
|
||||
|
||||
EncryptActivity modeInterface = (EncryptActivity) getActivity();
|
||||
EncryptModeFragment modeFragment = modeInterface.getModeFragment();
|
||||
|
||||
@@ -291,7 +291,7 @@ public class EncryptTextFragment
|
||||
private Intent createSendIntent(byte[] resultBytes) {
|
||||
Intent sendIntent;
|
||||
sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.setType(Constants.ENCRYPTED_TEXT_MIME);
|
||||
sendIntent.setType(Constants.MIME_TYPE_TEXT);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, new String(resultBytes));
|
||||
|
||||
EncryptActivity modeInterface = (EncryptActivity) getActivity();
|
||||
|
||||
@@ -98,7 +98,7 @@ public class NfcHelper {
|
||||
* guarantee that this activity starts when receiving a beamed message. For now, this code
|
||||
* uses the tag dispatch system.
|
||||
*/
|
||||
return new NdefMessage(NdefRecord.createMime(Constants.NFC_MIME,
|
||||
return new NdefMessage(NdefRecord.createMime(Constants.MIME_TYPE_KEYS,
|
||||
mNfcKeyringBytes), NdefRecord.createApplicationRecord(Constants.PACKAGE_NAME));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user