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

default to https instead of http for security benefits #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/rinku/rinku.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static autolink_parse_cb g_callbacks[] = {

static const char *g_hrefs[] = {
NULL,
"<a href=\"http://",
"<a href=\"https://",
"<a href=\"mailto:",
"<a href=\"",
};
Expand Down
11 changes: 6 additions & 5 deletions test/autolink_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
require 'rinku'

class RinkuAutoLinkTest < Minitest::Test

def generate_result(link_text, href = nil)
href ||= link_text
href = "http://" + href unless href =~ %r{\A(\w+://|mailto:)}
href = "https://" + href unless href =~ %r{\A(\w+://|mailto:)}
%{<a href="#{CGI.escapeHTML href}">#{CGI.escapeHTML link_text}</a>}
end

Expand All @@ -32,7 +33,7 @@ def test_global_skip_tags
assert_equal Rinku.skip_tags, ['pre']

Rinku.skip_tags = ['pa']
url = 'This is just a <pa>http://www.pokemon.com</pa> test'
url = 'This is just a <pa>https://www.pokemon.com</pa> test'
assert_equal Rinku.auto_link(url), url

Rinku.skip_tags = nil
Expand Down Expand Up @@ -76,7 +77,7 @@ def test_skips_tags
http://www.amd.com
</div>
<pre>
CODE <a href="http://www.less.es">www.less.es</a>
CODE <a href="https://www.less.es">www.less.es</a>
</pre>
result
assert_equal result, Rinku.auto_link(html, :all, nil, ["div", "a"])
Expand Down Expand Up @@ -232,10 +233,10 @@ def test_links_like_autolink_rails
email_result = %{<a href="mailto:#{email_raw}">#{email_raw}</a>}
email2_raw = '[email protected]'
email2_result = %{<a href="mailto:#{email2_raw}">#{email2_raw}</a>}
link_raw = 'http://www.rubyonrails.com'
link_raw = 'https://www.rubyonrails.com'
link_result = %{<a href="#{link_raw}">#{link_raw}</a>}
link2_raw = 'www.rubyonrails.com'
link2_result = %{<a href="http://#{link2_raw}">#{link2_raw}</a>}
link2_result = %{<a href="https://#{link2_raw}">#{link2_raw}</a>}
link3_raw = 'http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281'
link3_result = %{<a href="#{link3_raw}">#{link3_raw}</a>}
link4_raw = CGI.escapeHTML 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor123'
Expand Down