Do not return 'false' if IDNA<->UNICODE conversion fails #2479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR aim to accomplish?:
When we try
IDNA
to unicode conversion (or vice versa) the functions fails if the entered string is not a valid domain (e.g. to long).https://github.com/pi-hole/AdminLTE/blob/ad2d43869e9ad97cc3a8c5afc6fefec0e142a972/scripts/pi-hole/php/func.php#L629-L666
However, we usually immediately check the returned string right after conversion for validity and return a meaningful error message.
https://github.com/pi-hole/AdminLTE/blob/ad2d43869e9ad97cc3a8c5afc6fefec0e142a972/scripts/pi-hole/php/func.php#L13-L43
The issue occurs, when the conversion fails and no domain is entering
validDomain()
: it will always fail with the first (negative) matching test ("invalid characters") even if the reason is another one (e.g. too long domain).(This can be simply tested by trying to add a blacklist entry with one label >63 chars)
This PR mitigates the issue by checking if the conversion failed and returning the non-converted string.
By submitting this pull request, I confirm the following:
git rebase
)