commit c0734bbd88b6d5e366236ec5523510cfbfb4963d
Author: Juergen Spitzmueller <[email protected]>
Date: Thu Apr 3 11:35:36 2025 +0200
Disallow the use of commas in labels
This would break with references to multiple labels, as those
separate labels by comma
---
src/Text.cpp | 3 +++
src/frontends/qt/GuiLabel.cpp | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/src/Text.cpp b/src/Text.cpp
index ecc994db64..f53ab6aff5 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -2273,6 +2273,9 @@ docstring Text::getPossibleLabel(DocIterator const & cur)
const
// The return string of math matrices might contain linebreaks
par_text = subst(par_text, '\n', '-');
+ // commas are not allowed, as they are used to separate multiple
+ // in cross-references
+ par_text = subst(par_text, ',', '-');
int const numwords = 3;
for (int i = 0; i < numwords; ++i) {
if (par_text.empty())
diff --git a/src/frontends/qt/GuiLabel.cpp b/src/frontends/qt/GuiLabel.cpp
index ab902b187d..9cbff568f1 100644
--- a/src/frontends/qt/GuiLabel.cpp
+++ b/src/frontends/qt/GuiLabel.cpp
@@ -19,6 +19,7 @@
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
+#include <QRegularExpressionValidator>
using namespace std;
@@ -38,6 +39,9 @@ GuiLabel::GuiLabel(QWidget * parent) :
InsetParamsWidget(parent)
connect(keywordED, SIGNAL(textChanged(const QString &)),
this, SIGNAL(changed()));
+ QRegularExpression nocomma_re("[^,]+");
+ keywordED->setValidator(new QRegularExpressionValidator(nocomma_re,
keywordED));
+
setFocusProxy(keywordED);
}
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs