arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation

Home Page:http://libtorrent.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libtorrent strips off non-printable blank characters like `‎` or 'Left-to-right' markers in filenames

vincejv opened this issue · comments

Please provide the following information

libtorrent version (or branch): 2.0.9.0

platform/architecture: Linux/x86_64

compiler and compiler version: GNU 11.4.0, using QBT 4.6.2 and Deluge 2.1.1 to test

please describe what symptom you see, what you would expect to see instead and
how to reproduce it.

libtorrent strips off non-printable blank characters like '&lrm' or 'Left-to-right' markers in filenames causing it to not locate the files when seeding/uploading a torrent. Mktorrent, torrentfile and other torrent creation tools do not strip off these characters off these filenames. Torrent clients not using libtorrent like Transmission 4.0.4 also does not strip off these characters off the file names, so I'm not sure why libtorrent does this, is it another specification provided by BEP-8 or something similar?

I have opened a qBT issue regarding this and upon further investigation and cross testing with Deluge, it seems to be a libtorrent specific issue - qbittorrent/qBittorrent#20041

Sample torrent file:
Pokémon - S18E137 - The Wisdom Not to Run!‎ WEBDL-1080p.mkv.torrent.zip

Steps to reproduce:

  1. Import sample torrent file in libtorrent clients like QBT or Deluge
  2. QBT & Deluge thinks lrm character is not there and tries to look for it in file system
  3. QBT & Deluge reports file is missing even if file is there because the file system has the lrm character in place, but QBT/Deluge looks for the file without the lrm character

Potential impact as discussed in QBT GH

  • Original seeders/uploaders of the file
  • Missing files when migrating from/to non-libtorrent clients such as Transmission, uTorrent, Bittorrent

Also as per checking, only libtorrent does this, clients like Transmission, uTorrent, Bittorrent, and torrent creation tools like torf, torrentfile and mktorrent doesn't alter anything in the filenames, I don't see why libtorrent will go out of spec

https://github.com/arvidn/libtorrent/blob/9c1897645265c6a450930e766ab46c02a240891f/src/torrent_info.cpp#L102C8-L102C8

Thank's, if that's the case, I'll file an issue with all the other torrent tools and clients out there since it's supposed to be a security risk. There is a potential impact from users migrating torrent clients.