w3c / web-share-target

Web API proposal for receiving shared data
https://w3c.github.io/web-share-target/
Other
191 stars 20 forks source link

Skip bad files entries and make accept required #78

Closed ewilligers closed 5 years ago

ewilligers commented 5 years ago

If the name is an empty string, discard that files entry instead of rejecting the entire share target.

If an accept entry is invalid, discard that accept entry instead of rejecting either the files entry or the entire share target.

If accept is an empty array (either initially or because it only contained invalid entries), discard the files entry.

Note an an empty accept array previously had the opposite meaning, i.e. that the files entry accepted all files.

resolves #77


Preview | Diff

ewilligers commented 5 years ago

An alternate approach, if we wanted to discard only individual accept entries, might be to say that an empty accept array makes the whole files entry invalid. If people want to accept arbitarary files, that would be expessed explicitly with "accept": ["*/*"] instead of "accept": []

mgiuca commented 5 years ago

Instead of setting name to empty string, then later removing buckets with an empty name (which feels a bit round-about), could you just go back to the old logic, but replace "return undefined" with "remove bucket from the list and continue". In most programming languages, you're not supposed to delete an element from the array while iterating over it, but I don't see why we need to do that in "spec language".

mgiuca commented 5 years ago

@raymeskhoury FYI

ewilligers commented 5 years ago

The issue/PR came from a comment by @mounirlamouri.

Wording has been updated based on Matt's suggestion.

mgiuca commented 5 years ago

An alternate approach, if we wanted to discard only individual accept entries, might be to say that an empty accept array makes the whole files entry invalid. If people want to accept arbitarary files, that would be expessed explicitly with "accept": ["/"] instead of "accept": []

I think that's reasonable, considering most apps should be filtering by a particular format. If you really want to accept files of any type, you should have to ask for it.

mgiuca commented 5 years ago

So do you want to make the above change you suggested, or should I just approve this?

ewilligers commented 5 years ago

If you really want to accept files of any type, you should have to ask for it.

I've made the change.