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

Add support for Unicode links #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mukrop
Copy link

@mukrop mukrop commented Oct 27, 2019

@mukrop
Copy link
Author

mukrop commented Oct 27, 2019

Sorry it took so long, my past two weeks were also rather busy.

@keithmifsud
Copy link
Owner

Hi @mukrop ,

Thank for sharing your work :)

The travis checks are failing can you look into why, please?

Also, thank you for the version number :)

@mcrobs
Copy link

mcrobs commented Feb 10, 2020

The problem is that URI escape is deprecated, I suggest to use CGI.escape() instead. They do NOT behave in the same way, but in this particular case it does not matter how the URI is escaped, because this is for comparison only

lib/jekyll-target-blank.rb:196:21: W: Lint/UriEscapeUnescape: URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. 459 URI.parse(URI.escape(link)).host != URI.parse(URI.escape(@site_url)).host 460 ^^^^^^^^^^^^^^^^ 461lib/jekyll-target-blank.rb:196:57: W: Lint/UriEscapeUnescape: URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. 462 URI.parse(URI.escape(link)).host != URI.parse(URI.escape(@site_url)).host 463 ^^^^^^^^^^^^^^^^^^^^^

@keithmifsud
Copy link
Owner

The problem is that URI escape is deprecated, I suggest to use CGI.escape() instead. They do NOT behave in the same way, but in this particular case it does not matter how the URI is escaped, because this is for comparison only

lib/jekyll-target-blank.rb:196:21: W: Lint/UriEscapeUnescape: URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. 459 URI.parse(URI.escape(link)).host != URI.parse(URI.escape(@site_url)).host 460 ^^^^^^^^^^^^^^^^ 461lib/jekyll-target-blank.rb:196:57: W: Lint/UriEscapeUnescape: URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. 462 URI.parse(URI.escape(link)).host != URI.parse(URI.escape(@site_url)).host 463 ^^^^^^^^^^^^^^^^^^^^^

Thank you @mcrobs .. sorry for the cheeky request but is any chance you can update this PR by @mukrop to use the other parser, please?

If not I'll try to get to it asap but I'm rather busy and away from a Ruby IDE at this moment.

@mukrop
Copy link
Author

mukrop commented Feb 13, 2020

I do apologize for my inactivity, but I'm rather busy now. I'd be glad if you managed to resolve this without me.

@keithmifsud
Copy link
Owner

I understand and thank you for all your help in this 😄

@wbsmolen
Copy link

@mukrop @keithmifsud polite bump :)

@rafaelbiriba
Copy link

Any news on this one?

* In function 'external?', URI is now escaped before split.
* Class Addressable is used for parsing since it is capable of parsing Unicode URIs (IRIs). Another option would be to escape the URI before parsing but URI.escape is deprecated and alternatives (e.g. CGI.escape) work differently.
* Resolves keithmifsud#33.
@mukrop
Copy link
Author

mukrop commented Dec 5, 2020

Hi. I've looked into this after a longer while. In the end, I used the Addressable class for URI parsing as

  1. URI is not capable to process non-ascii characters (see https://bugs.ruby-lang.org/issues/12852)
  2. URI.escape is deprecated
  3. Alternatives such as CGI.escape do a different thing (they escape the :// that separates the protocol and thus breaks the parsing).

The tests now pass but the build fails on not finding .rubocop_todo.yml (which I don't understand and seems unrelated).

@keithmifsud keithmifsud added this to the Release v2.1 milestone Jan 19, 2021
@prplecake prplecake mentioned this pull request Mar 11, 2022
@jochenjonc
Copy link

@mukrop can we borough a little bit of your time to see if #61 is the fix for #46? Maybe just approving 2 PRs and creating a release could help a lot of us.

@mukrop
Copy link
Author

mukrop commented Jun 29, 2022

I'm off for the rest of the week but I believe I'll be able to find some time for this next week :-).

@mukrop
Copy link
Author

mukrop commented Jul 9, 2022

Hi. I've tested the patch, but the issue is not fixed, the error seems the same.

/usr/lib/ruby/2.7.0/uri/rfc3986_parser.rb:21:in `split': URI must be ascii only (URI::InvalidURIError)

@jochenjonc
Copy link

Hi. I've tested the patch, but the issue is not fixed, the error seems the same.

/usr/lib/ruby/2.7.0/uri/rfc3986_parser.rb:21:in `split': URI must be ascii only (URI::InvalidURIError)

Could it be that the code or test isn't using the Addressable implementation of URI, but still the standard on of Ruby?

@mukrop
Copy link
Author

mukrop commented Jul 9, 2022

Aah, sorry @jochenjonc, I misunderstood what I was supposed to check. I did it properly now and, indeed, #61 fixes the thing!

For testing purposes, I've added an extra commit to this PR replicating #61. For the sake of a clean codebase, I presume you want to merge #61 first and then merge this onto it without the replicating commit?

@jochenjonc
Copy link

@mukrop you can choose how to merge everything. None of the PRs are mine. 😉

@mukrop
Copy link
Author

mukrop commented Jul 9, 2022

Oh, and you are not the repository owner either, I thought you were :-).

@jochenjonc
Copy link

Funny, I thought you where the repo owner. 🤔

@jochenjonc
Copy link

@keithmifsud are you able to merge this PR and create a new release?

@keithmifsud
Copy link
Owner

Hi @jochenjonc ..I'll merge it asap. I need to remove the Travis CI check first but they seem to have changed the access. I'll get back to you asap.

The PR looks good. Thank you 😄

@jochenjonc
Copy link

@keithmifsud any luck on removing Travis CI check?

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.

Error: URI must be ascii only
6 participants