Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strings are strings after all #104

Merged
merged 7 commits into from
Jun 7, 2024
Merged

strings are strings after all #104

merged 7 commits into from
Jun 7, 2024

Conversation

dimbleby
Copy link
Owner

@dimbleby dimbleby commented May 26, 2024

A possible approach to restoring sanity on the interface and returning strings as &str.

Per c-ares/c-ares#769

  • very old versions of c-ares made no checks that strings were valid ascii
  • since 1.17.2, c-ares has validated that hostnames are valid strings
  • since version as-yet-unreleased, c-ares has validated that all of the other strings that it returns are valid strings

it's clearly desirable to return strings as &str on the rust bindings, but how to deal with the possibility that we are using an old c-ares that has not checked that this is true?

the approach here is: make use of rust's checking, and just fall over - unwrap() - if we receive a string that is not valid. The justification for that being something like:

  • this was, if you squint a bit, always how the c-ares API was supposed to work
  • so we view the 1.17.2 and as-yet-unreleased validation as bug fixes
  • in the unlikely event that anyone is making queries that return invalid strings, and they fall over, our answer is "yes that was a c-ares bug which you can resolve by updating to the latest version of that project"

obvs that last one only really works when as-yet-unreleased is in fact released

well I'm not going to release this immediately so I guess this pull request can sit here for a bit and I will see whether I still buy that reasoning later...

@dimbleby dimbleby force-pushed the strings-are-strings branch 2 times, most recently from aa6d25a to 6ae6a0b Compare May 26, 2024 18:13
@dimbleby dimbleby closed this Jun 7, 2024
@dimbleby dimbleby reopened this Jun 7, 2024
@dimbleby dimbleby merged commit 442b65d into main Jun 7, 2024
14 checks passed
@dimbleby dimbleby deleted the strings-are-strings branch June 7, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant