CodedOre / NewCaw

Development on Cawbird 2.0
GNU General Public License v3.0
97 stars 5 forks source link

Kludge a key length check for Twitter OAuth #59

Closed IBBoard closed 1 year ago

IBBoard commented 1 year ago

Meson seems to have limited tools for checking string lengths.

Hopefully helps with people hitting #57 in future

CodedOre commented 1 year ago

I'm not completely sure about checking that the key is exactly 34 characters long. I haven't seen it documented that a key is always that long. So there could be the possibility that this would block valid keys if they happen to be a bit longer or shorter...

Maybe we could just check that it is longer than a reasonable minimum, like 32? This should rule out old OAuth 1 keys but be more flexible should Twitter not always provide 34-long keys.

IBBoard commented 1 year ago

Yeah, I am making an assumption on length. But something that says "sorry, that's an old key" would be helpful.

Maybe if I switch it around and say "if key is less than 30 characters"? Which would just be:

if twitter_key.substring(0, 29) == twitter_key.substring(0, 30)
CodedOre commented 1 year ago

Yes, I think this could work.

CodedOre commented 1 year ago

Looks good to me, merging this.

eli-schwartz commented 1 year ago

Maybe you could add a small script that validates the key contents for well-formedness -- not limited to just length -- and check it with run_command()?

IBBoard commented 1 year ago

Presumably there is some standard definition to what they look like, so we could do a regex pattern. I could guess at one, but I wouldn't be confident that it wouldn't block valid values. It would be nice not to shell out, but it looks like Meson is too constrained for that.