integration_google icon indicating copy to clipboard operation
integration_google copied to clipboard

Files with '\r' character in the name stop migration

Open SergeyMosin opened this issue 2 years ago • 2 comments

Which version of integration_google are you using?

1.0.9

Which version of Nextcloud are you using?

25.0.10

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

Firefox

Describe the Bug

If google drive file has an \r character (char code 13) in the name migration stops.

The following error is logged:

[integration_google] Error: Google Drive import error: Unknown job failure. OCP\Files\NotFoundException in /var/www/html/lib/private/Files/Node/Node.php:113
Stack trace:
#0 /var/www/html/lib/private/Files/Node/Node.php(240): OC\Files\Node\Node->getFileInfo()
#1 /var/www/html/lib/private/Files/Node/Node.php(140): OC\Files\Node\Node->getPermissions()
#2 /var/www/html/lib/private/Files/Node/File.php(112): OC\Files\Node\Node->checkPermissions(3)
#3 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(649): OC\Files\Node\File->fopen('w')
#4 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(762): OCA\Google\Service\GoogleDriveAPIService->downloadAndSaveFile(Object(OC\Files\Node\Folder), 'char13\r.docx', 'admin3', 'https://www.goo...', Array, Array)
#5 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(427): OCA\Google\Service\GoogleDriveAPIService->getFile('admin3', Array, Object(OC\Files\Node\Folder), 'char13\r.docx')
#6 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(227): OCA\Google\Service\GoogleDriveAPIService->importFiles('admin3', '/Google Drive', 500000000, 0, 0, Array)
#7 /var/www/html/custom_apps/integration_google/lib/BackgroundJob/ImportDriveJob.php(38): OCA\Google\Service\GoogleDriveAPIService->importDriveJob('admin3')
#8 /var/www/html/lib/public/BackgroundJob/Job.php(78): OCA\Google\BackgroundJob\ImportDriveJob->run(Array)
#9 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(58): OCP\BackgroundJob\Job->start(Object(OC\BackgroundJob\JobList))
#10 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(48): OCP\BackgroundJob\QueuedJob->start(Object(OC\BackgroundJob\JobList))
#11 /var/www/html/cron.php(152): OCP\BackgroundJob\QueuedJob->execute(Object(OC\BackgroundJob\JobList), Object(OC\Log))
#12 {main}

Expected Behavior

This should be able to handle this case the same way filenames with an \n character are handled

Possible solution is to change

  $fileName = preg_replace('/\\n/', '', ...

to

  $fileName = preg_replace('/[\\r\\n]/', '', ...

here https://github.com/nextcloud/integration_google/blob/ea59710e7f4404b04289cc5506593ee100b8e96b/lib/Service/GoogleDriveAPIService.php#L606-L608

To Reproduce

Create a file with an \r character in the name and start migration.

One way to do it is via App Script https://developers.google.com/apps-script

Example:

function myFunction() {
  const doc = DocumentApp.create('char13name'+String.fromCharCode(13));
  const body = doc.getBody();
  body.appendParagraph("test char 13");
}

SergeyMosin avatar Sep 19 '23 20:09 SergeyMosin

Hello :wave: This issue appears to have had no activity for 3 months. We cannot keep track of whether individual issues have resolved themselves or still require attention without user interaction. We're thus adding the stale label to this issue to schedule it for getting closed in 5 days time. If you believe this issue is still valid and should be fixed, you can add a comment or remove the label to avoid it getting closed.

Cheers :blue_heart:

github-actions[bot] avatar Dec 19 '23 02:12 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Dec 24 '23 02:12 github-actions[bot]