[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh441: Do not allow 'top-level' outside of top-level (eac3fcd1)

PhelypeOleinik phelype.oleinik at latex-project.org
Mon Dec 14 12:38:46 CET 2020


Repository : https://github.com/latex3/latex2e
On branch  : hotfix/gh441
Link       : https://github.com/latex3/latex2e/commit/eac3fcd10a98492cd182d6cc5d7bbeaf89fb2737

>---------------------------------------------------------------

commit eac3fcd10a98492cd182d6cc5d7bbeaf89fb2737
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Dec 14 08:38:46 2020 -0300

    Do not allow 'top-level' outside of top-level


>---------------------------------------------------------------

eac3fcd10a98492cd182d6cc5d7bbeaf89fb2737
 base/lthooks.dtx | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 9aa3d48d..1c8f847b 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -2228,14 +2228,19 @@
 %    \begin{macrocode}
     \str_if_eq:nnTF {#2} { top-level }
       {
-        \debug_suspend:
+        \str_if_eq:eeTF { top-level }
+            { \@@_currname_or_default:n { top-level } }
+          {
+            \debug_suspend:
 %    \end{macrocode}
 %    If the hook's basic structure does not exist, we need to declare it
 %    with \cs{@@_declare:n}.
 %    \begin{macrocode}
-        \@@_declare:n {#1}
-        \tl_gput_right:cn { @@_toplevel~#1 } {#3}
-        \debug_resume:
+            \@@_declare:n {#1}
+            \tl_gput_right:cn { @@_toplevel~#1 } {#3}
+            \debug_resume:
+          }
+          { \msg_error:nnn { hooks } { misused-top-level } {#1} }
       }
       {
         \prop_get:cnNTF { g_@@_#1_code_prop } {#2} \l_@@_return_tl
@@ -3922,6 +3927,20 @@
 %    \end{macrocode}
 %    
 %    \begin{macrocode}
+\msg_new:nnnn { hooks } { misused-top-level }
+  {
+    Illegal~\iow_char:N \\AddToHook{#1}[top-level]{...}.\\
+    'top-level'~is~reserved~to~the~user's~document.\\
+  }
+  {
+    The~'top-level'~label~is~meant~for~user~code~only,~and~should~only~
+    be~used~by~the~user~(sparingly)~in~the~main~document.~Use~the~
+    proper~label~'\@@_currname_or_default:n { }'~for~this~\@cls at pkg,~or
+    another~suitable~label.
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \msg_new:nnn { hooks } { should-not-happen }
   {
     ERROR!~This~should~not~happen.~#1 \\





More information about the latex3-commits mailing list.