From d4f04513c23396b46dd0ab1ffdabdedbffe947ca Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 10 Feb 2014 09:23:17 +0100 Subject: [PATCH] Fix LFUN_MATH_AMS_MATRIX: it was possible to generate corrupt documents (part of #8359) --- src/LyXAction.cpp | 6 ++++-- src/mathed/InsetMathNest.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index a214cfe7bc..d100905f68 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1732,10 +1732,12 @@ void LyXAction::init() { LFUN_MATH_MATRIX, "math-matrix", Noop, Math }, /*! * \var lyx::FuncCode lyx::LFUN_MATH_AMS_MATRIX - * \li Action: Inserts a matrix. + * \li Action: Inserts an extended matrix as provided by the amsmath package. * \li Syntax: math-matrix [] * \li Params: : Decoration determines the LaTeX name of the matrix - that should be created. + that should be created. Possible values include + pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix and + matrix. The default is 'matrix'. * \li Sample: math-ams-matrix 3 3 bmatrix * \endvar */ diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index b9a2ed4098..3d31b9ac79 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1079,13 +1079,19 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) cur.recordUndo(); unsigned int m = 1; unsigned int n = 1; - docstring name; + docstring name = from_ascii("matrix"); idocstringstream is(cmd.argument()); is >> m >> n >> name; if (m < 1) m = 1; if (n < 1) n = 1; + // check if we have a valid decoration + if (name != "pmatrix" && name != "bmatrix" + && name != "Bmatrix" && name != "vmatrix" + && name != "Vmatrix" && name != "matrix") + name = from_ascii("matrix"); + cur.niceInsert( MathAtom(new InsetMathAMSArray(buffer_, name, m, n))); break; -- 2.39.2