Skip to main content

dotless

PyPI Pipeline Python versions License: GPL-3.0-or-later

Find the Turkish and Azerbaijani "I" bug in C/GLib, Vala, Python, JavaScript (gjs) and Rust code.

dotless scanning evolution-data-server

In Turkish and Azerbaijani, the upper-case form of i is İ and the lower-case form of I is ı. Code that changes case with the user's locale and then compares the result with an ASCII keyword breaks for everyone running tr_TR or az_AZ:

char *t = g_utf8_strdown (type, -1);   /* "INTEGER" -> "ınteger" in tr_TR */
if (strcmp (t, "integer") == 0)        /* never true for Turkish users   */
  ...
if (strcasecmp (ext, "ini") == 0)      /* "INI" != "ini" in tr_TR/az_AZ  */
Upper Lower
English I i
Turkish / Azerbaijani I ı
Turkish / Azerbaijani İ i

Why dotless?

This bug has been found and fixed one project at a time for decades. Python's codec lookup failed under Turkish locales because it normalised names with the C library's tolower() (bpo-1813, fixed 2011). LibreOffice's resource compiler had to be fixed to work in tr_TR.UTF-8 because of toupper()/tolower() (commit, 2016), and later failed to substitute configuration entries (tdf#125284, 2019). Geary did not sync mail from Gmail with LC_CTYPE=tr_TR.UTF-8 (GNOME bug 795906, fixed in 0.12.3). dotless looks for the pattern systematically.

Every rule is backed by a measurement, not by documentation alone: small probe programs run under C.UTF-8, tr_TR.UTF-8, az_AZ.UTF-8 and tr_TR.ISO-8859-9 in CI (docs/research.md). Some results were not what one would guess:

  • glibc's toupper('i') in a UTF-8 Turkish locale returns 'i', not İ: the answer does not fit in a byte, so the letter is left alone.
  • GLib only applies Turkic rules after the program calls setlocale(). Every GTK application does; a plain Rust binary using glib::ffi does not.
  • gjs and node disagree: toLocaleLowerCase() without arguments follows the locale in gjs but not in node 20.
  • musl (Alpine) has no Turkish case mapping at all; the bug is a glibc bug in practice, which is what GNOME distributions ship.
  • Python 3's str.lower() is locale independent. Only re.LOCALE on bytes is affected.

Install

pipx install dotless

or pip install dotless. dotless needs Python 3.9 or newer and has no dependencies. The development version installs with pipx install git+https://gitlab.com/rehimovv/dotless.git.

Usage

dotless scan path/to/project
Option
--format text|json|sarif|gitlab output format (default text)
--min-severity low|high hide low-severity findings
--output FILE write the report to a file
--exclude GLOB skip paths (repeatable); .git, build, subprojects, node_modules, po ... are skipped by default
--disable RULE turn a rule off, e.g. --disable DL005 (repeatable)
--color auto|always|never colour in the terminal; auto honours NO_COLOR and turns colour off when output is piped
--config FILE, --no-config read settings from another file, or ignore pyproject.toml
--force-exclude apply excludes to files named on the command line too
--exit-zero always exit with 0

dotless rules lists the rules and dotless --version prints the version.

Exit status: 0 nothing found, 1 findings reported, 2 usage or configuration error (unknown option or rule, missing path, invalid [tool.dotless]). Files that cannot be read are reported on stderr and skipped.

To silence a finding, add a comment dotless: ignore (or dotless: ignore[DL002]) on the same line or on the line above; dotless: ignore-file skips a file.

Configuration

dotless reads [tool.dotless] from the nearest pyproject.toml (in the current directory or a parent). Command line options take precedence.

[tool.dotless]
exclude = ["vendor", "tests/data/*"]
min-severity = "high"
disable = ["DL005"]

Reading pyproject.toml needs Python 3.11 or newer (tomllib). On 3.9 and 3.10 dotless prints a warning and ignores the table; command line options work everywhere.

pre-commit

repos:
  - repo: https://gitlab.com/rehimovv/dotless
    rev: v1.0.0
    hooks:
      - id: dotless

The hook passes --force-exclude, so exclude patterns from [tool.dotless] also apply to the files pre-commit hands over.

CI

GitLab — one line in .gitlab-ci.yml; findings show up in the merge request Code Quality widget:

include: 'https://gitlab.com/rehimovv/dotless/-/raw/main/ci/dotless.gitlab-ci.yml'

GitHub Actions — upload SARIF to code scanning:

- run: pipx install dotless
- run: dotless scan . --format sarif --output dotless.sarif --exit-zero
- uses: github/codeql-action/upload-sarif@v4
  with:
    sarif_file: dotless.sarif

Runtime check

dotless run -- ./my-program --some-args

runs the command under C.UTF-8, then under tr_TR.UTF-8 and az_AZ.UTF-8, and shows any difference in exit status, stdout or stderr. Messages stay untranslated (LANGUAGE=en), so differences come from the locale itself. Missing locales can be generated with localedef -i tr_TR -f UTF-8 tr_TR.UTF-8. Exit status: 0 same output, 1 differences, 2 the comparison could not run.

Severity

Only I/i behaves differently, so dotless can often tell whether a call is actually broken. A conversion is high when its result is compared with an ASCII constant containing the affected letter ("ini", "file", 'I'), or is looked up as a hash table key, config key, file extension, MIME type or protocol name. A comparison with a constant that has no i/I ("png") is the same in every locale and is not reported. Everything else is low. Details: docs/rules.md.

Languages and rules

Rule Language Flagged (locale-dependent) Not flagged (measured safe)
DL001 C, Rust libc:: tolower, toupper g_ascii_tolower, g_ascii_toupper
DL002 C, Rust libc:: strcasecmp, strncasecmp, strcasestr, wcscasecmp g_ascii_strcasecmp, g_ascii_strncasecmp
DL003 C towlower, towupper g_unichar_tolower, g_unichar_toupper
DL004 C, Python, gjs, Rust glib::ffi g_utf8_strdown, g_utf8_strup g_ascii_strdown, g_utf8_casefold
DL005 C g_strdown, g_strup, g_strcasecmp, g_strncasecmp (deprecated)
DL006 Vala string.down(), string.up() ascii_down(), ascii_up(), casefold()
DL007 JavaScript (gjs) toLocaleLowerCase(), toLocaleUpperCase() without a locale toLowerCase(), toUpperCase()
DL008 JavaScript localeCompare(..., {sensitivity: 'base'}) === 0 localeCompare for sorting
DL009 Python re.IGNORECASE | re.LOCALE str.lower(), str.upper(), str.casefold(), re.IGNORECASE
— Rust to_lowercase(), to_uppercase(), to_ascii_lowercase()

Bugs found

  • evolution-data-server: IMAP NIL detection and the NTLM LanManager hash use toupper(), so a lower-case nil is rejected and the LM response differs for passwords containing i under tr_TR/az_AZ (#677, reported).

A scan of ten GNOME modules and the reproducers behind this report are in reports/ and reproducers/.

Contributing

See CONTRIBUTING.md. False positives are bugs; please report them with the code that triggered them.

License

GPL-3.0-or-later.

Türkçe

dotless, büyük/küçük harf dönüşümünü sistem diline göre yapıp sonucu ASCII bir anahtar kelimeyle karşılaştıran kodu bulur. Bu tür kod tr_TR ve az_AZ yerellerinde bozulur: "INTEGER" küçültülünce "ınteger" olur, strcasecmp("INI", "ini") eşit dönmez.

pipx install dotless
dotless scan <dizin>

Ayarlar pyproject.toml içindeki [tool.dotless] tablosundan okunur (Python 3.11 ve üstü); pre-commit kancası ve GitLab/GitHub CI örnekleri yukarıdadır. Bir bulguyu susturmak için satıra dotless: ignore yorumu eklenir. Hangi fonksiyonun gerçekten yerele bağlı olduğu docs/research.md dosyasında ölçüm sonuçlarıyla belgelenmiştir.

Azərbaycanca

dotless böyük/kiçik hərf çevirməsini sistemin dilinə görə edib nəticəni ASCII açar sözlə müqayisə edən kodu tapır. Belə kod az_AZ və tr_TR lokallarında səhv işləyir: "INTEGER" kiçildiləndə "ınteger" olur, strcasecmp("INI", "ini") bərabər qaytarmır.

pipx install dotless
dotless scan <qovluq>

Parametrlər pyproject.toml faylındakı [tool.dotless] cədvəlindən oxunur (Python 3.11 və daha yeni); pre-commit və GitLab/GitHub CI nümunələri yuxarıdadır. Tapıntını susdurmaq üçün sətrə dotless: ignore şərhi əlavə olunur. Hansı funksiyanın həqiqətən lokaldan asılı olduğu docs/research.md faylında ölçmə nəticələri ilə sənədləşdirilib.

Metadata

Release files for dotless 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dotless 1.0.0
File Size Uploaded Provenance Actions
dotless-1.0.0.tar.gz 53.3 kB Without provenance Details for dotless-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dotless 1.0.0
File Interpreter ABI Platform Actions
dotless-1.0.0-py3-none-any.whl Python 3 none any Details for dotless-1.0.0-py3-none-any.whl

Total release size: 95.3 kB

Release files / dotless-1.0.0.tar.gz

Download URL dotless-1.0.0.tar.gz
Size 53.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b7a3956574a96655142efb993446e66c662e6f15f121ed8aa853bf04bf67fb7a
BLAKE2b-256 checksum
How to use checksums
593302b1cbb0b5f2230c33dd84f15b20387698fbaf418365002babda9ed36452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / dotless-1.0.0-py3-none-any.whl

Download URL dotless-1.0.0-py3-none-any.whl
Size 42.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef4de4aaf24be022d66b9d6a64b4bc873e65423fae3cb6ac8b89fa0d9bb6aa0e
BLAKE2b-256 checksum
How to use checksums
6e196a7bc37f2c55287e3bf2c08300344263e1e4fa1d43a044c2941467fbbf4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for dotless 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page