Thanks to visit codestin.com
Credit goes to github.com

Skip to content

\@currentlabelname is not correctly sanitized #64

@u-fischer

Description

@u-fischer

titlesec defines \@currentlabelname in \ttl@straight@i but doesn't sanitized the argument.

\def\ttl@straight@i#1[#2]#3{%
  \def\@currentlabelname{#2}% for nameref
  \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}%
  \let\ttl@savewrite\@empty
  \def\ttl@savetitle{#3}%
  \gdef\thetitle{\csname the#1\endcsname}%
  \if@noskipsec \leavevmode \fi
  \par
  \ttl@labelling{#1}{#2}%
  \ttl@startargs\ttl@straight@ii{#1}{#3}}

If nameref is loaded this more or less works, but without it it breaks in a current LaTeX which now stores the labelname too:

\documentclass{article}
\usepackage{titlesec}
\begin{document}
\section{a\label{b}}
\end{document}

gives

! TeX capacity exceeded, sorry [input stack size=10000].
\protect ->\noexpand \protect 
                              \noexpand 
l.217 \section{a\label{b}}

titlesec could load the gettitlestring package and then do:

\GetTitleString{#2}%
\let\@currentlabelname\GetTitleStringResult

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions