From a77ecb6d5d516b2ecc35b359f3a2be8696be4204 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 12 Oct 2018 23:45:49 +0200 Subject: [PATCH] change util::sanitise to filter out ' Only reatain chars, numbers and -_.+$()@ Allowing the appostroph seems entirely random and unjustified here --- src/lib/util.cpp | 2 +- src/lib/util.hpp | 20 ++++++++++---------- tests/15library.tests | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/util.cpp b/src/lib/util.cpp index 93920c1a1..bf192f190 100644 --- a/src/lib/util.cpp +++ b/src/lib/util.cpp @@ -57,7 +57,7 @@ namespace util { ChPredicate operator! (ChPredicate p) { return not bind(p,_1); } // character classes used for sanitising a string - ChPredicate isValid (is_alnum() or is_any_of("-_.+$'()@")); ///< characters to be retained + ChPredicate isValid (is_alnum() or is_any_of("-_.+$()@")); ///< characters to be retained ChPredicate isPunct (is_space() or is_any_of(",;:#*~´`?\\=/&%![]{}<>")); ///< punctuation to be replaced by '_' diff --git a/src/lib/util.hpp b/src/lib/util.hpp index 8e15d0872..493c25caa 100644 --- a/src/lib/util.hpp +++ b/src/lib/util.hpp @@ -336,8 +336,8 @@ namespace util { inline bool isSameObject (A const& a, B const& b) { - return static_cast (&a) - == static_cast (&b); + return static_cast (std::addressof(a)) + == static_cast (std::addressof(b)); } @@ -350,14 +350,14 @@ namespace util { * * @par Example Conversions \verbatim - "Word" --> 'Word' - "a Sentence" --> 'a_Sentence' - "trailing Withespace \t \n" --> 'trailing_Withespace' - "with a lot \nof Whitespace" --> 'with_a_lot_of_Whitespace' - "with\"much (punctuation)[]!" --> 'withmuch_(punctuation)' - "§&Ω%€ leading garbage" --> 'leading_garbage' - "mixed Ω garbage" --> 'mixed_garbage' - "Bääääh!!" --> 'Bh' + "Word" --> "Word" + "a Sentence" --> "a_Sentence" + "trailing Withespace \t \n" --> "trailing_Withespace" + "with a lot \nof Whitespace" --> "with_a_lot_of_Whitespace" + "@with\".\'much ($punctuation)[]!" --> "@with.much_($punctuation)" + "§&Ω%€ leading garbage" --> "leading_garbage" + "mixed Ω garbage" --> "mixed_garbage" + "Bääääh!!" --> "Bh" \endverbatim * @see \ref UtilSanitizedIdentifier_test * @see \ref lib::meta::sanitisedSymbol() diff --git a/tests/15library.tests b/tests/15library.tests index 03944a017..88c97555e 100644 --- a/tests/15library.tests +++ b/tests/15library.tests @@ -713,7 +713,7 @@ out-lit: 'trailing Withespace out-lit: ' --> 'trailing_Withespace' out-lit: 'with a lot out-lit: of Whitespace' --> 'with_a_lot_of_Whitespace' -out-lit: 'with"much (punctuation)[]!' --> 'withmuch_(punctuation)' +out-lit: '@with".'much (\$punctuation)[]!' --> '@with.much_(\$punctuation)' out-lit: '§&Ω%€ leading garbage' --> 'leading_garbage' out-lit: 'mixed Ω garbage' --> 'mixed_garbage' out-lit: 'Bääääh!!' --> 'Bh'