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
Add IDN support for redirects also #2424
Conversation
if the corrent PR is a solution for issue #2423 then we should consider centralizing this logic.. |
btw I am targeting 6.5 as a bugfix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments related to #2448. IMO it makes sense to include a fix for it here too, because you are changing the same piece of code.
src/functions.php
Outdated
* @return UriInterface | ||
* @internal | ||
*/ | ||
function _idn_uri_convert(UriInterface $uri, $options = IDNA_DEFAULT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about changing IDNA_DEFAULT
constant to 0
here? I'm think when intl
is not available it can cause an error...
See roundcube/roundcubemail#6244 for details, also related to #2448.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/functions.php
Outdated
function _idn_uri_convert(UriInterface $uri, $options = IDNA_DEFAULT) | ||
{ | ||
if ($uri->getHost()) { | ||
$asciiHost = idn_to_ascii($uri->getHost(), $options, INTL_IDNA_VARIANT_UTS46, $info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It make sense to use $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : null;
workaround here, because it seems that the constant is not always available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@alexeyshockov thank you for the review.. can you check again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still the UTS46 issue (read my comment and suggestion). Thanks a lot for your work.
src/functions.php
Outdated
$variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0; | ||
$asciiHost = idn_to_ascii($uri->getHost(), $options, $variant, $info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked locally, it raises a deprecation error (idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated
).
The only way is to call the function without the third argument at all, like here:
$asciiHost = defined('INTL_IDNA_VARIANT_UTS46')
? idn_to_ascii($uri->getHost(), $idnOptions, INTL_IDNA_VARIANT_UTS46, $info)
: idn_to_ascii($uri->getHost(), $idnOptions);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks again.. done..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so it's night and too many versions to keep in the head.
It works on my machine, because I have PHP 7.4 with already right defaults.
On 7.3 it raises a warning by default, if you don't specify INTL_IDNA_VARIANT_UTS46
manually. So there is basically no way to get rid of this deprecation error in PHP 7.2+ if you have an old version of ICU library. Looks like we have to disable idn_conversion
by default in this case (PHP 7.2+ and INTL_IDNA_VARIANT_UTS46
not defined).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better we avoid the back and forth :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but now it seems really out of scope here
So, how does this relate to #2454 ? Should the two be shipped in 6.5.1? |
Initially (when the issue with So the last changes (connected to
Don't see reasons not to do that. Or ship #2454 first and this one after, in |
Thanks @alexeyshockov ! If @gmponos can make the required changes we can release these fixes together. |
I will later today or tomorrow... |
@alexeyshockov I merged your changes from 6.5 branch. Would appreciate if you could re-validate this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this fix, looks good
@gmponos Can you please enable the intl extension in GH actions ci.yaml? I just saw that there is a condition for the intl extension being loaded. |
done on #2478 since current branch has tests under travis |
No description provided.