From 6918bb764fb59d4be551c12f99eb2fd0a5f11f00 Mon Sep 17 00:00:00 2001
From: Nick Timkovich <prometheus235@gmail.com>
Date: Mon, 29 Aug 2022 17:36:14 -0500
Subject: [PATCH] Strip newlines from token file

It's common for text editors and shell redirection to generate a file that ends in a newline, which is then extremely difficult, if not impossible, to enter into the browser.
---
 notebook/notebookapp.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py
index bd82f497ca..415af016dd 100755
--- a/notebook/notebookapp.py
+++ b/notebook/notebookapp.py
@@ -995,7 +995,7 @@ def _token_default(self):
         if os.getenv('JUPYTER_TOKEN_FILE'):
             self._token_generated = False
             with open(os.getenv('JUPYTER_TOKEN_FILE')) as token_file:
-                return token_file.read()
+                return token_file.read().strip("\n\r")
         if self.password:
             # no token if password is enabled
             self._token_generated = False