typos icon indicating copy to clipboard operation
typos copied to clipboard

Complains about base64 string

Open dpc opened this issue 2 years ago • 4 comments

We have some base64 encoded fixtured that trip typos:

error: `wel` should be `well`
  --> modules/fedimint-ln-tests/tests/tests.rs:120:50
    |
120 |         cqp2rzjq0ag45qspt2vd47jvj3t5nya5vsn0hlhf5wel8h779npsrspm6eeuqtjuuqqqqgqqyqqqqqqqqqqqqqqqc9q\
    |                                                  ^^^
    |
Typos found: Valid new words can be added to '_typos.toml'

I'll probably figure an workaround, but maybe worth mentioning so it can be improved? Maybe typos could detect long hex/baseN strings and ignore them?

dpc avatar Aug 27 '23 04:08 dpc

Maybe typos could detect long hex/baseN strings and ignore them?

Yes!!


[default]
extend-ignore-re = [
    "\\b[0-9A-Za-z+/]{91}(=|==)?\\b",
]

szepeviktor avatar Aug 27 '23 22:08 szepeviktor

Had to adapt this to \\b[0-9A-Za-z+/]{60}(=|==)?. Not sure why the remaining \\b did not make things work. I also saw that https://github.com/crate-ci/typos/pull/414 requires at least one + or / sign to trigger the escape. Which wasn't the case for my string: Wm4zWURqT3RVYXRTb0FHb1p4UGRrYmcKLS0tIDNFK3ZjUTZVclBaTlhFNSs5TEQ1

gibbz00 avatar Mar 18 '24 13:03 gibbz00

Which wasn't the case for my string:

Your string is 64 characters long. This configuration ignores it.

[default]
extend-ignore-re = [
    "\\b[0-9A-Za-z+/]{64}(=|==)?\\b",
]

... I think you mean the built-in base64-ignoring rule.

szepeviktor avatar Mar 18 '24 13:03 szepeviktor

Um no, I tried 60 chars both with and without the remaining \\b. Positive it's the cause 😊

gibbz00 avatar Mar 18 '24 13:03 gibbz00