Skip to content

BUG Defining cryptfiles.include encrypts files but does not decrypt them #20

@sc0ttdav3y

Description

@sc0ttdav3y

Describe the bug

Following the README, I've added the following to plugin.xml so I can support json files being encrypted.

    <cryptfiles>
        <include>
            <file regex="\.(htm|html|js|css|json)$" />
        </include>
        <exclude>
        </exclude>
    </cryptfiles>

During build-time I see the files here are encrypted, but at run-time they are not decrypted. The reason is the DecryptResource.java class is not getting updated with the file regex, and it still has the default list:

  private static final String[] CRYPT_FILES = {
    ".htm",
    ".html",
    ".js",
    ".css",
  };

I see code in after_prepare.js that intends to change the class, but it is targeting INCLUDE_FILES and EXCLUDE_FILES properties in the Java source, rather than CRYPT_FILES which is in the source here:

private static final String[] CRYPT_FILES = {
.

My workaround is to manually edit the Java class to add the extension.

To Reproduce

Steps to reproduce the behavior:

  1. add a custom extension into plugin.xml as above
  2. compile an app that requires a file of that type

Expected behavior

The app should decrypt the read when it is called.

Additional information

I notice that the original plugin cordova-plugin-crypt-file does have INCLUDE_FILES and EXCLUDE_FILES, so it's possibly just a back-porting issue:

https://github.com/tkyaji/cordova-plugin-crypt-file/blob/ddee9dfcbf082c417a41b8480f7a9d2b7884ed87/src/android/com/tkyaji/cordova/DecryptResource.java#L29

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions