From 4bf281106b401c34669dd66b7711705a7a212d7f Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 17 Nov 2010 21:19:01 +0000 Subject: [PATCH] Be more careful here about isalpha and isalnum. Per Enrico's suggestion, we first do a range test, then check the status. I think this is right in both cases. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36351 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetRef.cpp | 5 +++-- src/output_xhtml.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 8baf6c6e82..aa0bcb573e 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -114,8 +114,9 @@ docstring InsetRef::getFormattedCmd(docstring const & ref, // make sure the prefix is legal for a latex command int const len = prefix.size(); for (int i = 0; i < len; i++) { - if (!isalpha(prefix[i])) { - LYXERR0("Prefix `" << prefix << "' contains non-letters."); + char_type c = prefix[i]; + if (c >= 0x80 || !isalpha(prefix[i])) { + LYXERR0("Prefix `" << prefix << "' is invalid for LaTeX."); // restore the label label = ref; return defcmd; diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index f6ab5a5a02..40759cea40 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -128,11 +128,11 @@ docstring cleanAttr(docstring const & str) docstring newname; docstring::const_iterator it = str.begin(); docstring::const_iterator en = str.end(); - for (; it != en; ++it) - if (isalnum(*it)) - newname += *it; - else - newname += '_'; + for (; it != en; ++it) { + char_type const c = *it; + bool const is_alnum = c < 0x80 && isalnum(c); + newname += is_alnum ? c : char_type('_'); + } return newname; } -- 2.39.2