Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1f218d8 authored by Akhil's avatar Akhil 🙂
Browse files

Removed notes patch as issue seems to be fixed

parent 742dd453
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -74,8 +74,7 @@ RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-
RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i ${TMP_PATCH_DIR}/004-contact-search-controller-removal.patch
RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-core.patch
RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch
RUN patch -u ${BASE_DIR}/custom_apps/notes/lib/Service/NoteUtil.php -i ${TMP_PATCH_DIR}/006-notes-url-fix.patch
RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/007-recovery-email-changes.patch
RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.patch
RUN rm -rf ${TMP_PATCH_DIR}

# autocomplete leak tweak apps frontend with sed, disable group suggestion

patches/006-notes-url-fix.patch

deleted100644 → 0
+0 −52
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Mon, 21 Dec 2020 13:47:24 +0530
Subject: [PATCH] Changes for notes with long filenames that generate endless recursion and memory issues

This patch replaces a buggy recursion method with an iterative procedure. When there is a very long filename the recursion doesn't end. An iterative procedure works well.

diff --git ../../notes-3.6.4/lib/Service/NoteUtilOriginal.php ../../notes-3.6.4/lib/Service/NoteUtil.php
--- ../../notes-3.6.4/lib/Service/NoteUtilOriginal.php	2020-12-21 13:45:50.215222624 +0530
+++ ../../notes-3.6.4/lib/Service/NoteUtil.php	2020-12-21 13:47:24.277418659 +0530
@@ -86,23 +86,25 @@
 
 		// if file does not exist, that name has not been taken. Similar we don't
 		// need to handle file collisions if it is the filename did not change
-		if (!$folder->nodeExists($filename) || $folder->get($filename)->getId() === $id) {
-			return $filename;
-		} else {
-			// increments name (2) to name (3)
-			$match = preg_match('/\((?P<id>\d+)\)$/u', $title, $matches);
-			if ($match) {
-				$newId = ((int) $matches['id']) + 1;
-				$newTitle = preg_replace(
-					'/(.*)\s\((\d+)\)$/u',
-					'$1 (' . $newId . ')',
-					$title
-				);
-			} else {
-				$newTitle = $title . ' (2)';
-			}
-			return $this->generateFileName($folder, $newTitle, $suffix, $id);
-		}
+		while($folder->nodeExists($filename) ) {
+                        $file = $folder->get($filename);
+                        if($file && $file->getId() === $id) {
+                           return $filename;
+                        }
+                        $match = preg_match('/\((?P<id>\d+)\)$/u', $title, $matches);
+                                        if ($match) {
+                                                        $newId = ((int) $matches['id']) + 1;
+                                                        $title = preg_replace(
+                                                                        '/(.*)\s\((\d+)\)$/u',
+                                                                        '$1 (' . $newId . ')',
+                                                                        $title
+                                                        );
+                                        } else {
+                                                        $title = $title . ' (2)';
+                                        }
+                        $filename = $title . $suffix;
+                }
+                return $filename;
 	}
 
 	public function getSafeTitle(string $content) : string {