Fix #11235: LaTeX: `\color` may cause color leaks in topic or notices

This commit is contained in:
Jean-François B
2023-03-12 15:55:57 +01:00
parent 428097f305
commit aeeadb6f1e
3 changed files with 43 additions and 10 deletions

View File

@@ -35,6 +35,8 @@ Bugs fixed
shadow color is set but border color is not
* LaTeX: fix unintended 1pt upwards vertical shift of code blocks frames
respective to contents (when using rounded corners)
* #11235: LaTeX: added ``\color`` in topic (or admonition) contents may cause color
leak to the shadow and border at a page break
* #11147: Fix source file/line number info in object description content and in
other uses of ``nested_parse_with_titles``. Patch by Jeremy Maitin-Shepard.

View File

@@ -1243,8 +1243,7 @@ forget the underscore separating the prefix from the attribute name.
``{gray}{0.95}``. They previously defaulted to black, respectively white.
For all other types, the border color defaults to black and the background
color to white (technically, the LaTeX code does not even bother injecting
color commands then).
color to white.
.. note::

View File

@@ -344,7 +344,13 @@
\vbox{%
\moveright\spx@boxes@shadow@xoffset
\hbox{\lower\spx@boxes@shadow@yoffset
\vbox{\ifspx@boxes@withshadowcolor\color{spx@boxes@shadowcolor}\fi
\vbox{\ifspx@boxes@withshadowcolor
\color{spx@boxes@shadowcolor}%
\else
% 6.2.0: guard against a manually inserted \color command in
% contents which could leak at a page break to the shadow
\normalcolor
\fi
\ifdim\spx@boxes@shadow@yoffset<\z@
\hrule\@height-\spx@boxes@shadow@yoffset
\kern\spx@boxes@shadow@yoffset
@@ -371,7 +377,13 @@
}% end of \vbox
\fi % end of shadow drawing, and we are back to horizontal reference point
% BOX BORDER
\vbox{\ifspx@boxes@withbordercolor\color{spx@boxes@bordercolor}\fi
\vbox{\ifspx@boxes@withbordercolor
\color{spx@boxes@bordercolor}%
\else
% 6.2.0: guard against a \color command in contents whose effect
% could leak to border at a pagebreak
\normalcolor
\fi
\hrule\@height\spx@boxes@border@top
\kern-\spx@boxes@border@top
\setbox\spx@tempboxb\hb@xt@\wd\spx@tempboxa
@@ -421,7 +433,13 @@
% BOX SHADOW
% draw shadow and move back to reference point
\ifspx@boxes@withshadow
\hbox{\vbox{\ifspx@boxes@withshadowcolor\color{spx@boxes@shadowcolor}\fi
\hbox{\vbox{\ifspx@boxes@withshadowcolor
\color{spx@boxes@shadowcolor}%
\else
% 6.2.0: guard against a manually inserted \color command in
% contents which could leak at a page break to the shadow
\normalcolor
\fi
% NOTA BENE
% We deliberately draw shadow partially under an area later covered by frame
% with the idea to avoid anti-aliasing problems but in fact this may be a bad
@@ -453,7 +471,13 @@
}% end of \hbox, attention its depth is only |yoffset| if yoffset<0
\fi % end of inset shadow drawing, and we are back to horizontal reference point
% BOX BORDER
\vbox{\ifspx@boxes@withbordercolor\color{spx@boxes@bordercolor}\fi
\vbox{\ifspx@boxes@withbordercolor
\color{spx@boxes@bordercolor}%
\else
% 6.2.0: guard against a \color command in contents whose effect
% could leak to border at a pagebreak
\normalcolor
\fi
\hrule\@height\spx@boxes@border@top
\kern-\spx@boxes@border@top
\setbox\spx@tempboxb\hb@xt@\wd\spx@tempboxa
@@ -600,9 +624,14 @@
(\strip@pt\dimexpr-.5\spx@boxes@border\relax,\strip@pt\dimexpr-.5\spx@boxes@border\relax)%
\ifspx@boxes@withshadow
{% <-- added scope limitation at 6.2.0, as shadowcolor was leaking to border if
% bordercolor not explicitly set
% Should an \else branch be added with \normalcolor?
\ifspx@boxes@withshadowcolor\color{spx@boxes@shadowcolor}\fi
% bordercolor was not explicitly set
\ifspx@boxes@withshadowcolor
\color{spx@boxes@shadowcolor}%
\else
% 6.2.0: guard against a manually inserted \color command in
% contents which could leak at a page break to the shadow
\normalcolor
\fi
\put(\strip@pt\dimexpr\ifdim\spx@boxes@shadow@xoffset<\z@-\fi
0.5\spx@boxes@border+\spx@boxes@shadow@xoffset\relax,%
\strip@pt\dimexpr\ifdim\spx@boxes@shadow@yoffset<\z@\else-\fi
@@ -623,7 +652,10 @@
% stroke will produce a visible contour, so we exclude doing it in that case
\ifspx@boxes@withbordercolor
\color{spx@boxes@bordercolor}%
% Should an \else branch use \normalcolor?
\else
% 6.2.0: guard against a \color command in contents whose effect
% could leak to border at a pagebreak
\normalcolor
\fi
\linethickness{\spx@boxes@border}%
\ifdim\spx@boxes@border@top=\z@