eiri commented on a change in pull request #817: Don't crash on invalid inline attachments URL: https://github.com/apache/couchdb/pull/817#discussion_r138927023
########## File path: src/couch/src/couch_att.erl ########## @@ -412,13 +412,21 @@ follow_from_json(Att, Props) -> inline_from_json(Att, Props) -> B64Data = couch_util:get_value(<<"data">>, Props), - Data = base64:decode(B64Data), - Length = size(Data), - RevPos = couch_util:get_value(<<"revpos">>, Props, 0), - store([ - {data, Data}, {revpos, RevPos}, {disk_len, Length}, - {att_len, Length} - ], Att). + try base64:decode(B64Data) of + Data -> + Length = size(Data), + RevPos = couch_util:get_value(<<"revpos">>, Props, 0), + store([ + {data, Data}, {revpos, RevPos}, {disk_len, Length}, + {att_len, Length} + ], Att) + catch + _:_ -> Review comment: I thought about it, but then decided to opt out. We don't particularly interested in _how_ `base64` can't decode our data, only in fact that it can't be decoded, so there are no merit to try and match all possible ways `base64` can break, if at the end we are raising the same invalid request exception. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services