Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
SergeyMosin opened this issue Sep 19, 2023 · 2 comments
Closed

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

SergeyMosin opened this issue Sep 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@SergeyMosin
Copy link
Contributor

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

private function getFileName(array $fileItem, string $userId, bool $hasNameConflict): string {
$fileName = preg_replace('/\\n/', '', preg_replace('/\//', '-', $fileItem['name'] ?? 'Untitled'));

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 SergeyMosin added the bug Something isn't working label Sep 19, 2023
Copy link

Hello 👋
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 💙

@github-actions github-actions bot added the Stale label Dec 19, 2023
Copy link

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 24, 2023
@marcelklehr marcelklehr reopened this Mar 1, 2024
@marcelklehr marcelklehr removed the Stale label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants