Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden pgfmathparser against active chars #1221

Merged
merged 3 commits into from Oct 23, 2023

Conversation

josephwright
Copy link
Contributor

In general, the grabbed token could always be active, so precautions are needed. Here, the places that the grabbed token is tested and those where it's used in a csname are addressed. The tests need \noexpand, the csname usage \string, with appropriate expansion.

In general, the grabbed token could always be
active, so precautions are needed.

Signed-off-by: Joseph Wright <joseph.wright@morningstar2.co.uk>
Signed-off-by: Joseph Wright <joseph.wright@morningstar2.co.uk>
Signed-off-by: Joseph Wright <joseph.wright@morningstar2.co.uk>
@hmenke
Copy link
Member

hmenke commented Nov 30, 2022

Looks good, thanks! Could you please add a few tests?

@josephwright
Copy link
Contributor Author

Looks good, thanks! Could you please add a few tests?

I'll work on it: the tests I have locally also depend on another patch that's a bit harder to articulate just yet. Later today ...

% ...or a base prefix...
\expandafter\ifx\csname pgfmath@base@\pgfmath@number\pgfmath@token\endcsname\relax%
\expandafter\ifx\csname pgfmath@base@\expandafter\pgfmath@number\expandafter\string\pgfmath@token\endcsname\relax%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\expandafter\ifx\csname pgfmath@base@\expandafter\pgfmath@number\expandafter\string\pgfmath@token\endcsname\relax%
\expandafter\ifx\csname pgfmath@base@\pgfmath@number\expandafter\string\pgfmath@token\endcsname\relax%

It seems the first added \expandafter is unnecessary.

@@ -509,7 +509,7 @@
\else%
% ...here, it is a base prefix 0x, 0X, 0b or 0B
\expandafter\let\expandafter\pgfmath@base\expandafter=%
\csname pgfmath@base@\pgfmath@number\pgfmath@token\endcsname%
\csname pgfmath@base@\expandafter\pgfmath@number\expandafter\string\pgfmath@token\endcsname%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\csname pgfmath@base@\expandafter\pgfmath@number\expandafter\string\pgfmath@token\endcsname%
\csname pgfmath@base@\pgfmath@number\expandafter\string\pgfmath@token\endcsname%

@hmenke hmenke merged commit dc8e666 into pgf-tikz:master Oct 23, 2023
muzimuzhi added a commit that referenced this pull request Oct 23, 2023
Signed-off-by: muzimuzhi <muzimuzhi@gmail.com>
loopspace pushed a commit to loopspace/pgf that referenced this pull request Apr 2, 2024
Signed-off-by: muzimuzhi <muzimuzhi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants