From c00d9ed697319c88897192f96a36f1eba8b110b9 Mon Sep 17 00:00:00 2001 From: Nishant Das Patnaik Date: Sun, 9 Apr 2017 18:16:46 -0700 Subject: [PATCH] bug fix --- database/__init__.py | 22 +++++++++++++--------- scripts/Android/Network/HTTP.js | 6 +++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/database/__init__.py b/database/__init__.py index 2595fe8..70a60e1 100644 --- a/database/__init__.py +++ b/database/__init__.py @@ -19,15 +19,19 @@ from xml.sax.saxutils import escape def save_to_database(db_path, str_json): - str_json = json.loads(str_json) - db = dataset.connect('sqlite:///%s' % (db_path.replace("'", "_"))) - table = db['api_captures'] - table.insert(dict(time=time.strftime('%b %d %Y %l:%M %p', time.localtime()), - operation=str_json['txnType'], - artifact=json.dumps(str_json['artifact']), - method=str_json['method'], - module=str_json['lib'], - remark='')) + try: + str_json = json.loads(str_json.replace("\n", "
").replace("\r", "
"), strict=False) + db = dataset.connect('sqlite:///%s' % (db_path.replace("'", "_"))) + table = db['api_captures'] + table.insert(dict(time=time.strftime('%b %d %Y %l:%M %p', time.localtime()), + operation=str_json['txnType'], + artifact=json.dumps(str_json['artifact']), + method=str_json['method'], + module=str_json['lib'], + remark='')) + except Exception as e: + print str(e) + print str_json def stringify(data): str_data = "" diff --git a/scripts/Android/Network/HTTP.js b/scripts/Android/Network/HTTP.js index 275dd02..408ece5 100644 --- a/scripts/Android/Network/HTTP.js +++ b/scripts/Android/Network/HTTP.js @@ -26,9 +26,9 @@ Java.perform(function() { try { var HttpURLConnection = Java.use("com.android.okhttp.internal.http.HttpURLConnectionImpl"); } catch (e) { - var HttpURLConnection = Java.use("com.android.okhttp.internal.huc.HttpURLConnectionImpl"); - } finally { - return + try { + var HttpURLConnection = Java.use("com.android.okhttp.internal.huc.HttpURLConnectionImpl"); + } catch (e) { return } } //var BufferedInputStream = Java.use("java.io.BufferedInputStream"); //var StringBuilder = Java.use("java.lang.StringBuilder");