Skip to content

Commit 1c810ed

Browse files
authored
Replace non-ASCII characters (em/en dash, arrow) with ASCII equivalents in regex files
1 parent 6d07e4d commit 1c810ed

6 files changed

Lines changed: 134 additions & 134 deletions

File tree

cpp/ql/lib/semmle/code/cpp/regex/RegexFlowConfigs.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* All standard `std::regex` grammars are now modeled: ECMAScript (default),
1717
* POSIX BRE (`basic`/`grep`), and POSIX ERE (`extended`/`egrep`/`awk`).
18-
* Grammar selection and ReDoS-eligibility are independent axes see
18+
* Grammar selection and ReDoS-eligibility are independent axes - see
1919
* `isBacktrackingEngine` for the latter.
2020
*/
2121

@@ -375,13 +375,13 @@ predicate hasNonEcmaScriptGrammarFlag(StringLiteral regex) {
375375
/**
376376
* The `std::regex` grammar dialects that the C++ regex parser is aware of.
377377
*
378-
* - `Ecma()` ECMAScript, the default grammar used by `std::regex`.
378+
* - `Ecma()` - ECMAScript, the default grammar used by `std::regex`.
379379
* Selected either implicitly (no explicit grammar flag) or
380380
* explicitly via `std::regex_constants::ECMAScript`. Modeled
381381
* by `EcmaRegExp`.
382-
* - `Bre()` POSIX Basic Regular Expressions (selected via the `basic`
382+
* - `Bre()` - POSIX Basic Regular Expressions (selected via the `basic`
383383
* or `grep` flags). Modeled by `BreRegExp`.
384-
* - `Ere()` POSIX Extended Regular Expressions (selected via the
384+
* - `Ere()` - POSIX Extended Regular Expressions (selected via the
385385
* `extended`, `egrep`, or `awk` flags). Modeled by
386386
* `EreRegExp`.
387387
*
@@ -402,9 +402,9 @@ newtype TRegexGrammar =
402402
* construction-site `syntax_option_type` flag argument (if any).
403403
*
404404
* The mapping is:
405-
* - `basic` / `grep` `Bre()`
406-
* - `extended` / `egrep` / `awk` `Ere()`
407-
* - anything else (default, explicit `ECMAScript`, or unresolved) `Ecma()`
405+
* - `basic` / `grep` -> `Bre()`
406+
* - `extended` / `egrep` / `awk` -> `Ere()`
407+
* - anything else (default, explicit `ECMAScript`, or unresolved) -> `Ecma()`
408408
*
409409
* Every case now has a concrete parser subclass, so `hasConcreteGrammar`
410410
* holds for the result of this predicate.

cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ module Impl implements RegexTreeViewSig {
196196
// RegExpTerm (base class for all parse-tree nodes)
197197
// -------------------------------------------------------------------------
198198
/**
199-
* A regular expression term a node in the parse tree of a regex literal.
199+
* A regular expression term - a node in the parse tree of a regex literal.
200200
*/
201201
class RegExpTerm extends RegExpParent {
202202
RegExp re;
@@ -426,7 +426,7 @@ module Impl implements RegexTreeViewSig {
426426
// Sequences and alternations
427427
// -------------------------------------------------------------------------
428428
/**
429-
* A sequence term two or more items in a row.
429+
* A sequence term - two or more items in a row.
430430
*
431431
* Example: `ab` is a sequence of `a` and `b`.
432432
*/
@@ -504,7 +504,7 @@ module Impl implements RegexTreeViewSig {
504504
class RegExpCharEscape = RegExpEscape;
505505

506506
/**
507-
* An escaped regular expression term starts with `\` and is not a
507+
* An escaped regular expression term - starts with `\` and is not a
508508
* back-reference.
509509
*/
510510
class RegExpEscape extends RegExpNormalChar {
@@ -538,7 +538,7 @@ module Impl implements RegexTreeViewSig {
538538
}
539539

540540
/**
541-
* A character-class escape an escape that denotes a set of characters.
541+
* A character-class escape - an escape that denotes a set of characters.
542542
*
543543
* Examples: `\d`, `\D`, `\w`, `\W`, `\s`, `\S`.
544544
*/
@@ -569,10 +569,10 @@ module Impl implements RegexTreeViewSig {
569569
* (complementary class escapes).
570570
*/
571571
predicate isUniversalClass() {
572-
// [^] empty inverted class
572+
// [^] - empty inverted class
573573
this.isInverted() and not exists(this.getAChild())
574574
or
575-
// [\w\W] and similar two complementary class escapes
575+
// [\w\W] and similar - two complementary class escapes
576576
not this.isInverted() and
577577
exists(string cce1, string cce2 |
578578
cce1 = this.getAChild().(RegExpCharacterClassEscape).getValue() and
@@ -650,8 +650,8 @@ module Impl implements RegexTreeViewSig {
650650
* Each is treated as a single character-matching atom (a class member).
651651
*
652652
* For POSIX character classes with a clean Perl-escape equivalent
653-
* (`digit`, `space`, `word`) or a *subset* of one (`alpha`, `alnum`,
654-
* `upper`, `lower`, `xdigit`, `blank`) we map them onto `\d`, `\s`, `\w`
653+
* (`digit`, `space`, `word`) - or a *subset* of one (`alpha`, `alnum`,
654+
* `upper`, `lower`, `xdigit`, `blank`) - we map them onto `\d`, `\s`, `\w`
655655
* via `isEscapeClass`, so the shared ReDoS engine can reason about their
656656
* match sets.
657657
*
@@ -742,7 +742,7 @@ module Impl implements RegexTreeViewSig {
742742
* `RegexFlowConfigs.qll` (`hasMultilineFlag`) and exposed by
743743
* `RegExpLiteral.isMultiline()`, but the shared `RegexTreeViewSig`
744744
* signature has no hook to parameterize anchor semantics on multiline
745-
* mode. We therefore always model `$` as the end-of-string anchor
745+
* mode. We therefore always model `$` as the end-of-string anchor -
746746
* mirroring the conservative choice made by the JavaScript and Ruby
747747
* ReDoS analyses. Under `multiline`, `$` can additionally match at `\n`,
748748
* which affects rejecting-suffix reasoning for `^`/`$`-anchored
@@ -927,7 +927,7 @@ module Impl implements RegexTreeViewSig {
927927
// RegExpConstant
928928
// -------------------------------------------------------------------------
929929
/**
930-
* A constant regular expression term a sequence of characters that matches
930+
* A constant regular expression term - a sequence of characters that matches
931931
* a fixed string. Currently this is always a single character (or escape
932932
* sequence).
933933
*/
@@ -972,7 +972,7 @@ module Impl implements RegexTreeViewSig {
972972
or
973973
// Map POSIX bracket sub-expressions to the shared engine's escape-class
974974
// signature. Only POSIX character classes (`[:name:]`) whose match set
975-
// is `\d`, `\s`, or `\w` or a subset of one are mapped; other
975+
// is `\d`, `\s`, or `\w` - or a subset of one - are mapped; other
976976
// POSIX classes (`punct`, `cntrl`, `print`, `graph`) and the
977977
// collating/equivalence forms have no meaningful escape-class equivalent
978978
// and are left opaque (they still parse as single character-class atoms,
@@ -983,7 +983,7 @@ module Impl implements RegexTreeViewSig {
983983
name = posix.getName()
984984
|
985985
// `[:digit:]` = `\d`; `[:xdigit:]` is a superset, treated as `\d`
986-
// (under-approximation sound for the shared engine's overlap
986+
// (under-approximation - sound for the shared engine's overlap
987987
// reasoning, since it will only ever detect fewer intersections, not
988988
// invent them).
989989
name = ["digit", "xdigit"] and clazz = "d"

0 commit comments

Comments
 (0)