Skip to content

Releases

v0.2.0

Choose a tag to compare

@kenshaw kenshaw released this 26 Nov 06:45

v0.2.0 follows upstream github.com/gobwas/glob by behavior, adds the glob syntax of the shells, and makes each match take linear time.

Changes that can change a match

  • A malformed pattern is an error: an unclosed {, [ or (, a trailing \, and a pattern that is not valid UTF-8 (D8).
  • [^...] is a negation, as [!...] is. Before, it matched ^ (D9).
  • The extended groups of bash, ?() *() +() @() !(), are on by default. A pattern that held @( as text now holds a group (D10).
  • a*ant no longer matches ant, and a/**/b no longer matches a/b without WithGlobstar (issues 51, 58, 61 and 76 of upstream).

New

  • Bracket expressions follow POSIX, with named classes such as [[:alpha:]] (D9).
  • Brace sequences, such as {1..10}, {01..10..2} and {a..e} (D11).
  • CompileWith with the options WithSeparators, WithFold and WithGlobstar, and the functions New, MatchBytes and Separators (D13, D16, D17).
  • The types Path and Host, which also unmarshal from text (D14).
  • Quote escapes the comma too (D15).

Speed and safety

  • Each match takes time linear in the length of the input, so a glob is safe on input that you do not trust. Before, *a*a*a*a*b took 40 seconds on 400 bytes. A group such as +(*a) can take quadratic time (D20).
  • A match of most patterns does not allocate. A match with WithFold does not copy input that is lower case already.
  • Compile takes less time and fewer allocations.
  • Fixed faults: a * crossed a separator when there were several separators, a separator that is not ASCII could panic, and input that is not valid UTF-8 could match wrongly.

Tests

  • 2,336 test vectors from a survey of 11 glob implementations.
  • Fuzz tests compare the optimized matchers with a reference matcher, and give any bytes to the compiler.

The decisions are in docs/decisions. Decisions D7 to D20 are proposed.

⌂ 换网址