Skip to content

v0.3.0

Choose a tag to compare

@mostafa-mansour1 mostafa-mansour1 released this 01 Oct 10:17
· 1 commit to master since this release

Works on current Cordova and Capacitor again. Tested on cordova-android 14 and 15, cordova-ios 8, and Capacitor 7 and 8.

  • (Security, iOS and Android) the name option was used as a file path as-is, so a name such as ../file wrote outside the plugin's folder (and on iOS deleted the existing file there first). This could be exploited when an app passes a server-supplied file name. Only the last path component of name is used now.
  • (Security, Android) removed debug logging that printed full URLs and file paths to logcat; signed URLs could leak access tokens there.
  • (Privacy, iOS) previewed and downloaded files are now saved in the app's temporary folder instead of Documents, so they are no longer kept indefinitely or included in device backups. If your app relied on finding previewed files in Documents, save a copy yourself before previewing.
  • (Privacy, Android) the plugin no longer requests the WRITE_EXTERNAL_STORAGE permission. It never needed it: files are written to app-specific storage. If your app needs that permission for its own code, declare it in your app's config.xml.
  • (Android) replace the pinned androidx.appcompat:appcompat:1.3.1 with androidx.core:core:1.13.0, the library the plugin actually uses. Supported Cordova and Capacitor versions already include it, so app dependency versions do not change.
  • (iOS) fix build on cordova-ios 8: the plugin no longer compiled, and its cordova-plugin-add-swift-support dependency failed during install. That dependency is removed; cordova-ios 8 supports Swift natively.
  • (iOS) a remote URL that returns an HTTP error (404, 403, ...) now calls the error callback instead of previewing the error page as the file.
  • (iOS) URLs that are already percent-encoded are no longer encoded twice, which broke signed URLs and file names containing #, spaces or accents (#45).
  • (Android) fix blank documents: local and base64 files opened in the viewer as empty pages on current cordova-android, because the plugin's FileProvider shared its class name with cordova-android's own provider. The plugin now uses its own provider class (com.mostafa.previewanyfile.PreviewAnyFileProvider), authority (<applicationId>.previewanyfile.provider) and paths file (res/xml/preview_any_file_paths.xml), so it no longer conflicts with Capacitor or other plugins either.
  • (Android) remove the cordova-plugin-androidx and cordova-plugin-androidx-adapter dependencies, which are not needed on supported platforms (#44).
  • previewAsset now calls the error callback when the asset cannot be loaded (it previously only logged to the console).
  • Declare minimum platforms (cordova-android 14, cordova-ios 8). Cordova projects on older platforms keep installing 0.2.9.
  • README: Capacitor install, requirements and tested versions, nativeURL vs toURL(), Android remote URL behaviour, working Ionic wrapper link (#47).

Install

cordova plugin add cordova-plugin-preview-any-file

Capacitor:

npm install cordova-plugin-preview-any-file
npx cap sync

Upgrading from 0.2.x? See the upgrade notes.