@@ -66,7 +66,7 @@ func decodeFileSpecStreamDict(sd *types.StreamDict, id string) error {
6666 return sd .Decode ()
6767}
6868
69- func fileSpectStreamFileName (xRefTable * XRefTable , d types.Dict ) (string , error ) {
69+ func fileSpecStreamFileName (xRefTable * XRefTable , d types.Dict ) (string , error ) {
7070 o , found := d .Find ("UF" )
7171 if found {
7272 fileName , err := xRefTable .DereferenceStringOrHexLiteral (o , V10 , nil )
@@ -105,7 +105,7 @@ func fileSpecStreamDict(xRefTable *XRefTable, d types.Dict) (*types.StreamDict,
105105}
106106
107107// NewFileSpectDictForAttachment returns a fileSpecDict for a.
108- func (xRefTable * XRefTable ) NewFileSpectDictForAttachment (a Attachment ) (* types.IndirectRef , error ) {
108+ func (xRefTable * XRefTable ) NewFileSpecDictForAttachment (a Attachment ) (* types.IndirectRef , error ) {
109109 modTime := time .Now ()
110110 if a .ModTime != nil {
111111 modTime = * a .ModTime
@@ -115,7 +115,15 @@ func (xRefTable *XRefTable) NewFileSpectDictForAttachment(a Attachment) (*types.
115115 return nil , err
116116 }
117117
118- d , err := xRefTable .NewFileSpecDict (a .ID , types .EncodeUTF16String (a .ID ), a .Desc , * sd )
118+ // TODO insert (escaped) reverse solidus before solidus between file name components.
119+
120+ // TODO Migrate to UTF-8 for both F and UF
121+ s , err := types .EscapeUTF16String (a .ID )
122+ if err != nil {
123+ return nil , err
124+ }
125+
126+ d , err := xRefTable .NewFileSpecDict (a .ID , * s , a .Desc , * sd )
119127 if err != nil {
120128 return nil , err
121129 }
@@ -138,7 +146,7 @@ func fileSpecStreamDictInfo(xRefTable *XRefTable, id string, o types.Object, dec
138146 }
139147 }
140148
141- fileName , err := fileSpectStreamFileName (xRefTable , d )
149+ fileName , err := fileSpecStreamFileName (xRefTable , d )
142150 if err != nil {
143151 return nil , "" , "" , nil , err
144152 }
@@ -210,7 +218,7 @@ func (ctx *Context) AddAttachment(a Attachment, useCollection bool) error {
210218 }
211219 }
212220
213- ir , err := xRefTable .NewFileSpectDictForAttachment (a )
221+ ir , err := xRefTable .NewFileSpecDictForAttachment (a )
214222 if err != nil {
215223 return err
216224 }
0 commit comments