Meteor-files: link() crashes if extension exists but has no value

Created on 9 Dec 2017  路  3Comments  路  Source: veliovgroup/Meteor-Files

Our app started to crash because

const vRef = ((fileRef.versions && fileRef.versions[version]) || fileRef);

  if (_.has(vRef, 'extension')) {
    ext = `.${vRef.extension.replace(/^\./, '')}`;
  } else {
    ext = '';
  }

https://github.com/VeliovGroup/Meteor-Files/blob/master/lib.js#L71

just checks if the property exists (_.has) and doesn't check if a value is given/or value is a string. The default schema sets extension to string, the value is optional (keep in mind that versions are also affected as they have an extension field too).

Yes, the first solution should be to fix the database, but also I think that link() should be more fail-safe in this case.

.link() bug enhancement

Most helpful comment

@menelike thank you, fixed and published as v1.9.3

All 3 comments

@menelike thank you, fixed and published as v1.9.3

@dr-dimitru
Thank you for your support and the speed you maintain this project. You are doing a very good job here! Applause!

you're welcome menelike

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ck23onGithub picture ck23onGithub  路  3Comments

Avijobo picture Avijobo  路  3Comments

RE-N-Y picture RE-N-Y  路  3Comments

owenhoskins picture owenhoskins  路  3Comments

sylido picture sylido  路  3Comments