diff --git a/rpc.js b/rpc.js index 3ad1a9a42..9cdb440f3 100644 --- a/rpc.js +++ b/rpc.js @@ -992,6 +992,9 @@ var owned_upload_complete = function (Env, safeKey, cb) { } var oldPath = makeFilePath(Env.paths.staging, safeKey); + if (typeof(oldPath) !== 'string') { + return void cb('EINVAL_CONFIG'); + } // construct relevant paths var root = Env.paths.staging; @@ -1054,6 +1057,9 @@ var owned_upload_complete = function (Env, safeKey, cb) { })); }).nThen(function (w) { // move the existing file to its new path + + // flow is dumb and I need to guard against this which will never happen + /*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */ Fs.rename(oldPath /* XXX */, finalPath, w(function (e) { if (e) { w.abort(); @@ -1217,7 +1223,6 @@ RPC.create = function ( var pinPath = paths.pin = keyOrDefaultString('pinPath', './pins'); var blobPath = paths.blob = keyOrDefaultString('blobPath', './blob'); var blobStagingPath = paths.staging = keyOrDefaultString('blobStagingPath', './blobstage'); - console.log(blobStagingPath); var isUnauthenticateMessage = function (msg) { return msg && msg.length === 2 && isUnauthenticatedCall(msg[0]); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index bb285e3dc..778e7fb04 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -241,7 +241,6 @@ define([ type: 'radio', name: 'cp-share-editable', value: 1, - checked: 'checked' }), h('label', { 'for': 'cp-share-editable-true' }, Messages.share_linkEdit), h('input#cp-share-editable-false.cp-share-editable-value', { @@ -271,12 +270,12 @@ define([ ]); if (!hashes.editHash) { $(link).find('#cp-share-editable-false').attr('checked', true); - $(link).find('#cp-share-editable-true').attr('disabled', true); + $(link).find('#cp-share-editable-true').removeAttr('checked').attr('disabled', true); } var saveValue = function () { - var edit = $(link).find('#cp-share-editable-true').is(':checked'); - var embed = $(link).find('#cp-share-embed').is(':checked'); - var present = $(link).find('#cp-share-present').is(':checked'); + var edit = Util.isChecked($(link).find('#cp-share-editable-true')); + var embed = Util.isChecked($(link).find('#cp-share-embed')); + var present = Util.isChecked($(link).find('#cp-share-present')); common.setAttribute(['general', 'share'], { edit: edit, embed: embed, @@ -285,9 +284,9 @@ define([ }; var getLinkValue = function (initValue) { var val = initValue || {}; - var edit = initValue ? val.edit : $(link).find('#cp-share-editable-true').is(':checked'); - var embed = initValue ? val.embed : $(link).find('#cp-share-embed').is(':checked'); - var present = initValue ? val.present : $(link).find('#cp-share-present').is(':checked'); + var edit = initValue ? val.edit : Util.isChecked($(link).find('#cp-share-editable-true')); + var embed = initValue ? val.embed : Util.isChecked($(link).find('#cp-share-embed')); + var present = initValue ? val.present : Util.isChecked($(link).find('#cp-share-present')); var hash = (edit && hashes.editHash) ? hashes.editHash : hashes.viewHash; var href = origin + pathname + '#' + hash; @@ -372,10 +371,11 @@ define([ common.getAttribute(['general', 'share'], function (err, val) { val = val || {}; if (val.edit === false) { - $(link).find('#cp-share-editable-false').attr('checked', true); + $(link).find('#cp-share-editable-false').prop('checked', true); } - if (val.embed) { $(link).find('#cp-share-embed').attr('checked', true); } - if (val.present) { $(link).find('#cp-share-present').attr('checked', true); } + else { $(link).find('#cp-share-editable-true').prop('checked', true); } + if (val.embed) { $(link).find('#cp-share-embed').prop('checked', true); } + if (val.present) { $(link).find('#cp-share-present').prop('checked', true); } $(link).find('#cp-share-link-preview').val(getLinkValue(val)); }); common.getMetadataMgr().onChange(function () { @@ -1681,7 +1681,7 @@ define([ $element.attr('data-type', p); $element.click(function () { $modal.hide(); - if ($advanced && $advanced.is(':checked')) { + if ($advanced && Util.isChecked($advanced)) { common.sessionStorage.put(Constants.displayPadCreationScreen, true, function (){ common.openURL('/' + p + '/'); }); diff --git a/www/common/common-util.js b/www/common/common-util.js index 98eda7373..a67ba6673 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -246,6 +246,21 @@ define([], function () { } }; + Util.isChecked = function (el) { + // could be nothing... + if (!el) { return false; } + // check if it's a dom element + if (typeof(el.tagName) !== 'undefined') { + return Boolean(el.checked); + } + // sketchy test to see if it's jquery + if (typeof(el.prop) === 'function') { + return Boolean(el.prop('checked')); + } + // else just say it's not checked + return false; + }; + return Util; }); }(self));