nickva commented on a change in pull request #817: Don't crash on invalid 
inline attachments
URL: https://github.com/apache/couchdb/pull/817#discussion_r138927161
 
 

 ##########
 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:
   Yap got it, that makes sense
 
----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to