Skip to content

Commit

Permalink
Merge pull request #265 from nextcloud/backport/257/skip-on-error
Browse files Browse the repository at this point in the history
[stable13] Skip parameters which are not there instead of failing out
  • Loading branch information
MorrisJobke authored Apr 18, 2018
2 parents db25925 + c8ceafb commit 973410f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions js/richObjectStringParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* later. See the COPYING file.
*/

(function() {
(function(OC, OCA, Handlebars) {
OCA.Activity = OCA.Activity || {};

OCA.Activity.RichObjectStringParser = {
Expand Down Expand Up @@ -45,8 +45,13 @@

_.each(matches, function(parameter) {
parameter = parameter.substring(1, parameter.length - 1);
var parsed = self.parseParameter(parameters[parameter]);
if (!parameters.hasOwnProperty(parameter) || !parameters[parameter]) {
// Malformed translation?
console.error('Potential malformed ROS string: parameter {' + parameter + '} was found in the string but is missing from the parameter list');
return;
}

var parsed = self.parseParameter(parameters[parameter]);
subject = subject.replace('{' + parameter + '}', parsed);
});

Expand Down Expand Up @@ -148,7 +153,7 @@
parameter.path = parameter.path.substring(firstSlashPosition === 0 ? 1 : 0, lastSlashPosition);

if (!parameter.link) {
parameter.link = OC.generateUrl('/f/{fileId}', {fileId: parameter.id})
parameter.link = OC.generateUrl('/f/{fileId}', {fileId: parameter.id});
}

if (parameter.path === '' || parameter.path === '/') {
Expand All @@ -160,4 +165,4 @@
}
};

})();
})(OC, OCA, Handlebars);

0 comments on commit 973410f

Please sign in to comment.