The following MCE:
\documentclass{article}\usepackage{hyperref}\ExplSyntaxOn\NewDocumentCommand { \foo } { s m } { \IfBooleanTF {#1}{ Foo~ #2 }{ #2 }}\pdfstringdefDisableCommands{ \def\foo*#1{Foo~ #1} % \def\foo#1{#1}}\ExplSyntaxOff\begin{document}\section{\foo*{bar}}% \section{\foo{bar}}\end{document}
compiles like a charm, except if the \section{\foo{bar}}
is uncommented, the error message being in such a case:
! Use of \foo doesn't match its definition.<argument> ...rline {\csname thesection\endcsname }\fi \foo { bar}
Is there a way to use \pdfstringdefDisableCommands
with both starred and non starred commands?