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

Use libidn2 #133

Merged
7 commits merged into from Apr 28, 2022
Merged

Use libidn2 #133

7 commits merged into from Apr 28, 2022

Conversation

ghost
Copy link

@ghost ghost commented Feb 15, 2022

Purpose

Replace libidn with libidn2 following https://libidn.gitlab.io/libidn2/manual/libidn2.html#Converting-from-libidn.

Context

#131

Changes

  • update the Makefile.PL to look for libidn2 instead of libidn
  • use libidn2 header in include/LDNS.h
  • use new API in src/LDNS.xs

How to test this PR

The tests should pass.

Discussion

Old code was using IDNA_ALLOW_UNASSIGNED in idna_to_ascii_8z. Even if this flag exists in IDN2 (IDN2_ALLOW_UNASSIGNED) it seems it has been kept for compatibility reason and is unused. I haven't dig any further, but do we need to keep this flag, or should we update some logic in the code to keep the expected behavior we had with the old code?

Alexandre Pion added 3 commits February 15, 2022 17:30
The define  IDNA_ACE_PREFIX  is not defined in the  idn2.h  header.
Therefore we use another define  IDN2_OK  to test that the lib is
properly loaded.
@ghost ghost added this to the v2022.1 milestone Feb 15, 2022
@ghost ghost requested review from mattias-p, matsduf and vlevigneron February 15, 2022 16:46
@ghost ghost changed the base branch from master to develop February 15, 2022 16:47
@ghost ghost linked an issue Feb 15, 2022 that may be closed by this pull request
And not libidn11-dev anymore
@ghost
Copy link
Author

ghost commented Feb 15, 2022

Since #27 Travis always runs the tests with the network. Should I fix the test to be aligned with the live data? Or should we make the test run without network by default (so that on installation they are run in a close environment)?

@ghost
Copy link
Author

ghost commented Feb 16, 2022

I went with updating the tests. I realize that the nic.se zone has evolved recently. Maybe we should make a pass over the tests to reduce potential gaps with the current configuration.

The `se` and `nic.se` zones have evolved a little. The tests made over
the network using these zones have been slightly updated to fix errors
and be aligned with current zone configuration.
mattias-p
mattias-p previously approved these changes Feb 21, 2022
Copy link
Member

@mattias-p mattias-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mattias-p
Copy link
Member

Did you consider using https://metacpan.org/pod/Net::LibIDN2 instead? That way maybe we could simply drop some of our own XS code.

@ghost
Copy link
Author

ghost commented Feb 24, 2022

Did you consider using https://metacpan.org/pod/Net::LibIDN2 instead?

No I haven't. Thanks for the pointer.

@mattias-p mattias-p mentioned this pull request Mar 25, 2022
@matsduf
Copy link
Contributor

matsduf commented Apr 1, 2022

I think it would be a good idea to use Net::LibIDN2 instead. There is some magic that the IDN libraries do, such as down casing and making NFC. With Net::LibIDN2 we would have control of that. We could have a test case that verifies that labels that look like A-labels also are valid A-labels.

Would we loose anything by using Net::LibIDN2 instead?

@ghost ghost mentioned this pull request Apr 11, 2022
3 tasks
Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is #144 a proposed replacement of this PR?

@@ -18,8 +18,8 @@ to_idn(...)

if (SvPOK(ST(i)))
{
status = idna_to_ascii_8z(SvPVutf8_nolen(obj), &out, IDNA_ALLOW_UNASSIGNED);
if (status == IDNA_SUCCESS)
status = idn2_to_ascii_8z(SvPVutf8_nolen(obj), &out, IDN2_ALLOW_UNASSIGNED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flags we se are important. Is IDN2_ALLOW_UNASSIGNED really what we want here? The features that we select are important. This has to be investigated first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IDNA_ALLOW_UNASSIGNED has been used since the beginning of the to_idn() function. I've just tried to keep the same flag thinking it would give the same behavior. Are you saying that there is a change in behavior?

@matsduf
Copy link
Contributor

matsduf commented Apr 13, 2022

Should we have any discussion about this PR? I thought that this would be replaced by #144.

@ghost
Copy link
Author

ghost commented Apr 14, 2022

Since I don't think I'll be able to address #144 for v2022.1, I think it would be nice to integrate this change in v2022.1.

@matsduf, is the suggested flag correct? Do you see a change in behavior by using libidn2?

matsduf
matsduf previously approved these changes Apr 27, 2022
@ghost ghost dismissed stale reviews from matsduf and mattias-p via a97450c April 27, 2022 14:46
@ghost ghost requested a review from mattias-p April 28, 2022 08:51
@ghost ghost requested a review from matsduf April 28, 2022 08:52
@ghost
Copy link
Author

ghost commented Apr 28, 2022

I've seen I forgot to update the Dockerfile and some references to "libidn". This is fixed. Please re-review.

Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve.

@ghost ghost merged commit 9a01ac3 into zonemaster:develop Apr 28, 2022
@matsduf matsduf mentioned this pull request May 21, 2022
This pull request was closed.
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.

Migrate to libidn2?
2 participants