You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
Even with the restructuring, shouldn't we be checking that the URI is non-null and also content:? We know from the docs that it's invalid to call openTypedAssetFileDescriptor and we know from the issue that calling this with at least file: will throw an exception that can potentially bring down the whole app.
Hopefully moving getText up will avoid that in most cases, but we've had a lot of weird plugin bugs over the years that are related to other apps sending us bad data (e.g., intent responses that have unexpected nulls), so it seems like we should have a defense-in-depth approach here to make sure that if someone sends us a file: URI with no text it won't throw.
The reason will be displayed to describe this comment to others. Learn more.
I think that explicitly returning null in the case where the URI is null makes sense to make sure no weird errors come up like you're referencing.
In terms of adding a check for content: before calling openTypedAssetFileDescriptor, that makes sense as well; I initially assumed a FileNotFoundException would be thrown (which we catch) which does not seem to be the case (edit: I think this is the case for the text/* check actually).
I think it would also be helpful to add some logs to these new branches to make it clear why null is returned.
// Safely return clipbaord item into text by returning itemText or text retrieved
// from its URI.
return item.coerceToText(activity);
}
} catch (SecurityException e) {
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nonblocking nit: consider extracting uri logic into a method or methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved logic trying to extract text from URI to a new method!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undid this due to some recent changes here that actually made the new method more confusing.