File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 4040 "chai" : " ^4.2.0" ,
4141 "detect-node" : " ^2.0.4" ,
4242 "dirty-chai" : " ^2.0.1" ,
43- "ipfs-unixfs-importer" : " ~0.34 .0" ,
43+ "ipfs-unixfs-importer" : " ~0.36 .0" ,
4444 "ipld" : " ~0.20.0" ,
4545 "ipld-dag-pb" : " ~0.15.0" ,
4646 "pull-pushable" : " ^2.2.0" ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ function pathBaseAndRest (path) {
3131
3232 return {
3333 base : pathBase ,
34- rest : pathRest . split ( '/' ) . filter ( Boolean )
34+ rest : toPathComponents ( pathRest )
3535 }
3636}
3737
@@ -104,3 +104,11 @@ function join (paths) {
104104 return acc + path
105105 } , '' )
106106}
107+
108+ const toPathComponents = ( path = '' ) => {
109+ // split on / unless escaped with \
110+ return ( path
111+ . trim ( )
112+ . match ( / ( [ ^ \\ \] [ ^ / ] | \\ \/ ) + / g) || [ ] )
113+ . filter ( Boolean )
114+ }
Original file line number Diff line number Diff line change @@ -229,6 +229,34 @@ describe('exporter', () => {
229229 } )
230230 } )
231231
232+ it ( 'small file in a directory with an escaped slash in the title' , ( done ) => {
233+ const fileName = `small-\\/file-${ Math . random ( ) } .txt`
234+ const filePath = `/foo/${ fileName } `
235+
236+ pull (
237+ pull . values ( [ {
238+ path : filePath ,
239+ content : pull . values ( [ smallFile ] )
240+ } ] ) ,
241+ importer ( ipld ) ,
242+ pull . collect ( ( err , files ) => {
243+ expect ( err ) . to . not . exist ( )
244+
245+ const path = `/ipfs/${ new CID ( files [ 1 ] . multihash ) . toBaseEncodedString ( ) } /${ fileName } `
246+
247+ pull (
248+ exporter ( path , ipld ) ,
249+ pull . collect ( ( err , files ) => {
250+ expect ( err ) . to . not . exist ( )
251+ expect ( files . length ) . to . equal ( 1 )
252+ expect ( files [ 0 ] . path ) . to . equal ( fileName )
253+ done ( )
254+ } )
255+ )
256+ } )
257+ )
258+ } )
259+
232260 it ( 'exports a chunk of a file with no links' , ( done ) => {
233261 const offset = 0
234262 const length = 5
You can’t perform that action at this time.
0 commit comments