anchor.diff:          {ok, [{ok, Doc}]} = fabric:open_revs(Db, DocId, [Rev], [])
       end,
       UpdatedAtts = [
  -        #att{name=validate_attachment_name(Name),
  -            type=list_to_binary(ContentType),
  -            data=Content} ||
  +        couch_att:new([
  +            {name, validate_attachment_name(Name)},
  +            {type, list_to_binary(ContentType)},
  +            {data, Content}
  +        ]) ||
           {Name, {ContentType, _}, Content} <-
           proplists:get_all_values("_attachments", Form)
       ],
       #doc{atts=OldAtts} = Doc,
       OldAtts2 = lists:flatmap(
  -        fun(#att{name=OldName}=Att) ->
  -            case [1 || A <- UpdatedAtts, A#att.name == OldName] of
  +        fun(Att) ->
  +            OldName = couch_att:fetch(name, Att),
  +            case [1 || A <- UpdatedAtts, couch_att:fetch(name, A) == OldName] of
               [] -> [Att]; % the attachment wasn't in the UpdatedAtts, return it
               _ -> [] % the attachment was in the UpdatedAtts, drop it
               end
  
positive.code:         end,
          AttFun = case ReqAcceptsAttEnc of
          false ->
              fun couch_doc:att_foldl_decode/3;
          true ->
              fun couch_doc:att_foldl/3
          end,
          chttpd:etag_respond(
              Req,
  
negative.code: 
  
  validate_attachment_names(Doc) ->
      lists:foreach(fun(Att) ->
          Name = couch_att:fetch(name, Att),
          validate_attachment_name(Name)
      end, Doc#doc.atts).
  
  