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 entity-encoding for potential ‘mailto:’ prefix #9

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
10 changes: 3 additions & 7 deletions lib/jekyll/email-protect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ module EmailProtectionFilter

# Percent-encode alphanumeric characters of an email address
def encode_email(input)
input.to_s.chars.inject(String.new) do |result, char|
if char =~ /\p{Alnum}/
char.bytes.inject(result) do |result, byte|
result << '%%%02X' % byte
end
else
result << char
input.to_s.gsub(/(^mailto:)|\p{Alnum}+/) do |char|
char.bytes.inject(String.new) do |result, byte|
result << ($1 ? '&#%d;' : '%%%02X') % byte
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/email-protect/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Jekyll
module EmailProtect
VERSION = '1.0.3'
VERSION = '1.0.4'
end
end