Opened 7 years ago

Last modified 7 years ago

#1415 new defect

I2PSnark filename conversion to builtin charset in windows may cause data loss

Reported by: DjJeshk Owned by: zzz
Priority: major Milestone: 0.9.20
Component: apps/i2psnark Version: 0.9.17
Keywords: filenames corruption i2psnark Cc:
Parent Tickets: Sensitive: no


I2P version: 0.9.17-0
Java version: Oracle Corporation 1.7.0_71 (Java™ SE Runtime Environment 1.7.0_71-b14)
Wrapper version: 3.5.25
Server version: 8.1.16.v20140903
Servlet version: Jasper JSP 2.1 Engine
Platform: Windows XP x86 5.1
Processor: Core 2 (45nm) (core2)
Jbigi: Locally optimized native BigInteger? library loaded from file
Encoding: Cp1257
Charset: windows-1257

If torrent contains filename which contains a character which does not exist at system char set, it will be converted to


for example Sakın Bana Söyleme is converted to Sak_n Bana Söyleme.
If torrent contains two different filenames which converts to same filename it may cause unexpected behaviour including sending corrupted pieces to others or neverending torrents.

Reason: fixed width 1 byte long characters are in use which limits usable characters to 256 - 32 = 224 (first 32 characters are not allowed in filenames).

Solution: use bultin 2 byte long characters (wide chars, wchars, unicode characters) and leave one byte long character set for 1980s and 1990s, when Unicode was not implemented yet.


Change History (5)

comment:1 Changed 7 years ago by DjJeshk

Priority: criticalmajor

comment:2 Changed 7 years ago by zzz


Yes, duplicate names after character remapping is possible.

related: #571 #771 #1132

Has this happened to you on an actual torrent or is this a theoretical problem? If the former, please link to the torrent.

We can only create files using the character set that the platform supports. To fix, we will have to convert post-mapping duplicates to a unique name deterministically. It's not so simple as "using 2 byte characters".

comment:3 Changed 7 years ago by DjJeshk

Affected torrents:

These torrents were created and ran with Vuze (at 0.9.16 i2psnark had serveral problems that prevented to create torrents). I2P updated to 0.9.17 and i2psnark torrent creation started to work. I migrated torrents to i2psnark and some of them appeared incomplete. At filelist saw it has missing file named Sak_n Bana Söyleme and rendundant file named Sakın Bana Söyleme.

comment:4 Changed 7 years ago by zzz


This will be tricky to implement. Obviously we need to keep files in the same directory unique. We may or may not need to also keep directories unique. It could be acceptable to merge directories.

comment:5 Changed 7 years ago by zzz

Note: See TracTickets for help on using tickets.