cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rakatyal <...@git.apache.org>
Subject [GitHub] cordova-plugin-file pull request: CB-10798, CB-10384: Fixing permi...
Date Fri, 11 Mar 2016 23:30:35 GMT
Github user rakatyal commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-file/pull/170#discussion_r55904524
  
    --- Diff: src/android/FileUtils.java ---
    @@ -347,18 +348,25 @@ else if (action.equals("write")) {
                 threadhelper( new FileOp( ){
                     public void run(JSONArray args) throws JSONException, FileNotFoundException,
IOException, NoModificationAllowedException {
                         String fname=args.getString(0);
    +                    String nativeURL = resolveLocalFileSystemURI(fname).getString("nativeURL");
                         String data=args.getString(1);
                         int offset=args.getInt(2);
                         Boolean isBinary=args.getBoolean(3);
    -                    /*
    -                     * If we don't have the package name in the path, we're reading and
writing to places we need permission for
    -                     */
    -                    if(fname.contains(cordova.getActivity().getPackageName()) ||
    -                            hasReadPermission()) {
    -                        long fileSize = write(fname, data, offset, isBinary);
    -                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,
fileSize));
    +
    +                    JSONObject j = requestAllPaths();
    +                    String[] allowedStorageDirectories = {j.getString("applicationStorageDirectory"),
j.getString("externalApplicationStorageDirectory")};
    +                    boolean needWritePermission = true;
    +
    +                    // Ask for the write permission if the native url lies outside the
allowed storage directories
    +                    for(String directory : allowedStorageDirectories) {
    +                        if(nativeURL.startsWith(directory) || hasWritePermission()) {
    --- End diff --
    
    I don't think so. Can you think of a case this won't work?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message