summaryrefslogtreecommitdiffstats
path: root/core/js/share.js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-07-08 15:23:01 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-28 08:56:15 +0200
commitebfbb97e66ef5d4c3dbe6b2eb23d19cba9ab74bd (patch)
treecb7a73616acc4295095c57b4d0e2820a7bbc7ee2 /core/js/share.js
parentc683b1d3c9573260667c92587189723ab2905719 (diff)
downloadnextcloud-server-ebfbb97e66ef5d4c3dbe6b2eb23d19cba9ab74bd.tar.gz
nextcloud-server-ebfbb97e66ef5d4c3dbe6b2eb23d19cba9ab74bd.zip
Fix parsing of sharetime as string
In some cases the ajax/share.php will return the share time as string. If this is the case it would get parsed completely wrong and cause the share dropdown to not work anymore. This change will properly cast the string to an interger and also fallback if this is not possible.
Diffstat (limited to 'core/js/share.js')
-rw-r--r--core/js/share.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/js/share.js b/core/js/share.js
index d730d3bbf6e..f767da18da0 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -820,6 +820,21 @@ OC.Share={
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
},
/**
+ * Parses a string to an valid integer (unix timestamp)
+ * @param time
+ * @returns {*}
+ * @internal Only used to work around a bug in the backend
+ */
+ _parseTime: function(time) {
+ if (_.isString(time)) {
+ time = parseInt(time, 10);
+ if(isNaN(time)) {
+ time = null;
+ }
+ }
+ return time;
+ },
+ /**
* Displays the expiration date field
*
* @param {Date} date current expiration date
@@ -834,6 +849,8 @@ OC.Share={
minDate: minDate,
maxDate: null
};
+ // TODO: hack: backend returns string instead of integer
+ shareTime = OC.Share._parseTime(shareTime);
if (_.isNumber(shareTime)) {
shareTime = new Date(shareTime * 1000);
}