libglob: support "."/".." in file globs and fix patterns with trailing "/"

Fixes #12930.