cordova-plugin-mserviceinterface-2.0 1.0.35 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-mserviceinterface-2.0",
3
- "version": "1.0.35",
3
+ "version": "1.0.38",
4
4
  "description": "This plugin establishes the connection to the native interface and performs the requested task.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova-plugin-mserviceinterface-2.0"
5
- version="1.0.35">
5
+ version="1.0.38">
6
6
  <name>mserviceinterface-2.0</name>
7
7
  <description>This plugin establishes the connection to the native interface and performs the requested task.</description>
8
8
  <author>selfservit@gmail.com</author>
@@ -54,9 +54,9 @@ public class backgroundNotification extends NotificationExtenderService {
54
54
  String key = msgBody.getString("key");
55
55
  String subKey = msgBody.getString("subKey");
56
56
 
57
- if(scrID.equals("chat")) {
57
+ if(scrID.contains("_chat")) {
58
58
  if (!subKey.equals("")) {
59
- fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "content_store" + "/" + "msvMsg" + "/" + "history" + "/" + key + "/" + subKey);
59
+ fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "content_store" + "/" + "msvMsg" + "/" + "history"+ "/" + packageName + "/" + key + "/" + subKey);
60
60
  if (!fileDirectory.exists()) {
61
61
  fileDirectory.mkdirs();
62
62
  }
@@ -76,7 +76,7 @@ public class backgroundNotification extends NotificationExtenderService {
76
76
  System.out.println(line);
77
77
  }
78
78
  String notificationStr = decrypt(notificationDatas.toString());
79
- notificationStr = notificationStr + msgBody.toString() + ",";
79
+ notificationStr = notificationStr + "," +msgBody.toString() ;
80
80
  FileWriter fw = new FileWriter(notificationsFile);
81
81
  fw.write(mInterfaceUtil.encrypt(notificationStr));
82
82
  fw.close();
@@ -87,7 +87,7 @@ public class backgroundNotification extends NotificationExtenderService {
87
87
  System.out.println("Does not Exists");
88
88
  try {
89
89
  FileWriter fw = new FileWriter(notificationsFile);
90
- fw.write(mInterfaceUtil.encrypt(notification.payload.additionalData.getString("msgBody") + ","));
90
+ fw.write(mInterfaceUtil.encrypt(","+ notification.payload.additionalData.getString("msgBody")));
91
91
  fw.close();
92
92
  } catch (IOException e1) {
93
93
  e1.printStackTrace();
@@ -2262,6 +2262,15 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2262
2262
  while ((ze = zis.getNextEntry()) != null) {
2263
2263
  anyEntries = true;
2264
2264
  String compressedName = ze.getName();
2265
+ File outputFile = new File(outputDir, ze.getName());
2266
+ try {
2267
+ ensureZipPathSafety(outputFile, outputDirectory);
2268
+ } catch (Exception e) {
2269
+ anyEntries = false;
2270
+ e.printStackTrace();
2271
+ callbackContext.error("Bad zip file");
2272
+ return;
2273
+ };
2265
2274
  if (ze.isDirectory()) {
2266
2275
  File dir = new File(outputDirectory + compressedName);
2267
2276
  dir.mkdirs();
@@ -2297,6 +2306,13 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2297
2306
  }
2298
2307
  }
2299
2308
  }
2309
+ private void ensureZipPathSafety(final File outputFile, final String destDirectory) throws Exception {
2310
+ String destDirCanonicalPath = (new File(destDirectory)).getCanonicalPath();
2311
+ String outputFileCanonicalPath = outputFile.getCanonicalPath();
2312
+ if (!outputFileCanonicalPath.startsWith(destDirCanonicalPath)) {
2313
+ throw new Exception(String.format("Found Zip Path Traversal Vulnerability with %s", outputFileCanonicalPath));
2314
+ }
2315
+ }
2300
2316
 
2301
2317
  private Uri getUriForArg(String arg) {
2302
2318
  CordovaResourceApi resourceApi = webView.getResourceApi();
@@ -22,6 +22,7 @@ import android.os.Build;
22
22
  import android.os.Bundle;
23
23
  import android.os.Environment;
24
24
  import android.os.IBinder;
25
+ import android.os.Looper;
25
26
  import android.os.SystemClock;
26
27
  import android.support.annotation.NonNull;
27
28
  import android.support.annotation.Nullable;
@@ -295,7 +296,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
295
296
 
296
297
  }
297
298
  }
298
- PendingResult<Status> pendingResult = LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
299
+ PendingResult<Status> pendingResult = LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this, Looper.getMainLooper());
299
300
  }
300
301
 
301
302
  @Override