cgsecurity / testdisk

TestDisk & PhotoRec
https://www.cgsecurity.org/
GNU General Public License v2.0
1.55k stars 190 forks source link

Support for path that include Japanese text for QPhotoRec #63

Open Icy9ptcl opened 5 years ago

Icy9ptcl commented 5 years ago

Recently I tried to recover some files from .img file(that I grabbed from a 8GB SD card, which has corrupted partition table) and I found this issue:

QPhotoRec does not load .img files(or other images) from a folder/file that has any Japanese characters in its path.

I got this issue with the following environment:

How to reproduce:

  1. Put your .img file in a folder that has some Japanese characters (In my environment: "D:\作業フォルダ\Data.img" ) Note: You can include some Japanese characters in your file name instead of folder's name to reproduce this issue.
  2. Start QPhotoRec, choose "Add a raw disk image..." in the image selection, then select the file of step 1 (make sure to check the path to the file has at least 1 or more Japanese characters)
  3. Done! Nothing changes on GUI.

I also confirmed this issue with some other paths: "C:\ほげ\ABC.img" "C:\Hoge\ぷよ.img".

I got a bit worried but anyway I could recover my files from the image by moving it to D:\ . I must thank for this good software, anyway.

cgsecurity commented 5 years ago

The problem seems to be Windows specific. I have no problem with qphotorec under Linux. Extract from qphotorec.cpp

void QPhotorec::newSourceFile()
{
  const int testdisk_mode=TESTDISK_O_RDONLY|TESTDISK_O_READAHEAD_32K;
  QString filename = QFileDialog::getOpenFileName(this,
      tr("Please select a raw file"),
      "",
      tr("Raw Files (*.dd *.raw *.img)"));
  if(!filename.isEmpty())
  {
    disk_t *new_disk=NULL;
    QByteArray filenameArray= (filename).toUtf8();
    list_disk=insert_new_disk_aux(list_disk, file_test_availability(filenameArray.constData(), options->verbose, testdisk_mode), &new_disk);
    if(new_disk!=NULL)
    {
      select_disk(new_disk);
      HDDlistWidget_updateUI();
      PartListWidget_updateUI();
    }
  }
}