Giter VIP home page Giter VIP logo

rinku's Introduction

Rinku does linking

Build Status Dependency Status

Rinku is a Ruby library that does autolinking. It parses text and turns anything that remotely resembles a link into an HTML link, just like the Ruby on Rails auto_link method -- but it's about 20 times faster, because it's written in C, and it's about 20 times smarter when linking, because it does actual parsing instead of RegEx replacements.

Rinku is a Ruby Gem

Rinku is available as a Ruby gem:

$ [sudo] gem install rinku

The Rinku source is available at GitHub:

$ git clone git://github.com/vmg/rinku.git

Rinku is a standalone library

It exports a single method called Rinku.auto_link.

require 'rinku'

Rinku.auto_link(text, mode=:all, link_attr=nil, skip_tags=nil)
Rinku.auto_link(text, mode=:all, link_attr=nil, skip_tags=nil) { |link_text| ... }

Parses a block of text looking for "safe" urls or email addresses, and turns them into HTML links with the given attributes.

NOTE: The block of text may or may not be HTML; if the text is HTML, Rinku will skip the relevant tags to prevent double-linking and linking inside pre blocks by default.

NOTE: If the input text is HTML, it's expected to be already escaped. Rinku will perform no escaping.

NOTE: Currently the follow protocols are considered safe and are the only ones that will be autolinked.

http:// https:// ftp:// mailto://

Email addresses are also autolinked by default. URLs without a protocol specifier but starting with 'www.' will also be autolinked, defaulting to the 'http://' protocol.

  • text is a string in plain text or HTML markup. If the string is formatted in HTML, Rinku is smart enough to skip the links that are already enclosed in <a> tags.`

  • mode is a symbol, either :all, :urls or :email_addresses, which specifies which kind of links will be auto-linked.

  • link_attr is a string containing the link attributes for each link that will be generated. These attributes are not sanitized and will be include as-is in each generated link, e.g.

    auto_link('http://www.pokemon.com', :all, 'target="_blank"')
    # => '<a href="http://www.pokemon.com" target="_blank">http://www.pokemon.com</a>'

    This string can be autogenerated from a hash using the Rails tag_options helper.

  • skip_tags is a list of strings with the names of HTML tags that will be skipped when autolinking. If nil, this defaults to the value of the global Rinku.skip_tags, which is initially ["a", "pre", "code", "kbd", "script"].

  • &block is an optional block argument. If a block is passed, it will be yielded for each found link in the text, and its return value will be used instead of the name of the link. E.g.

    auto_link('Check it out at http://www.pokemon.com') do |url|
      "THE POKEMAN WEBSITEZ"
    end
    # => 'Check it out at <a href="http://www.pokemon.com">THE POKEMAN WEBSITEZ</a>'

Rinku is a drop-in replacement for Rails 3.1 auto_link

Auto-linking functionality has been removed from Rails 3.1, and is instead offered as a standalone gem, rails_autolink. You can choose to use Rinku instead.

require 'rails_rinku'
include ActionView::Helpers::TextHelper
post_body = "Welcome to my new blog at http://www.myblog.com/."
auto_link(post_body, :html => { :target => '_blank' }) do |text|
  truncate(text, :length => 15)
end
# => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.m...</a>."

The rails_rinku package monkeypatches Rails with an auto_link method that mimics 100% the original one, parameter per parameter. It's just faster.

Developing

$ gem install rake-compiler

$ rake

Rinku is written by me

I am Vicent Marti, and I wrote Rinku. While Rinku is busy doing autolinks, you should be busy following me on twitter. @vmg. Do it.

Rinku has an awesome license

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

rinku's People

Contributors

193s avatar bquorning avatar brianmario avatar erebor avatar grosser avatar henare avatar kivikakk avatar ktdreyer avatar rick avatar rtomayko avatar shajith avatar sr avatar vmg avatar waldyrious avatar watsonbox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rinku's Issues

Segfault when used in Rails with non-ascii chars

Hi,

it seems that Rinku (1.2.0) doesn't like non-ascii chars when used with Rails (3.0.9). For example, if I try this in the console:

Rinku.auto_link('héhé', :urls)

I got this segfault:

(pry):3: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]

-- control frame ----------
c:0023 p:---- s:0083 b:0083 l:000082 d:000082 CFUNC  :auto_link
c:0022 p:0019 s:0078 b:0078 l:0012d4 d:000077 EVAL   (pry):3
c:0021 p:---- s:0076 b:0076 l:000075 d:000075 FINISH
c:0020 p:---- s:0074 b:0074 l:000073 d:000073 CFUNC  :eval
c:0019 p:0241 s:0068 b:0067 l:000066 d:000066 METHOD /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:226
c:0018 p:0041 s:0060 b:0060 l:000059 d:000059 METHOD /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:193
c:0017 p:0012 s:0055 b:0055 l:000039 d:000054 BLOCK  /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:178
c:0016 p:---- s:0053 b:0053 l:000052 d:000052 FINISH
c:0015 p:---- s:0051 b:0051 l:000050 d:000050 CFUNC  :loop
c:0014 p:0040 s:0048 b:0048 l:000039 d:000047 BLOCK  /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:177
c:0013 p:---- s:0046 b:0046 l:000045 d:000045 FINISH
c:0012 p:---- s:0044 b:0044 l:000043 d:000043 CFUNC  :catch
c:0011 p:0080 s:0040 b:0040 l:000039 d:000039 METHOD /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:175
c:0010 p:0157 s:0032 b:0032 l:000031 d:000031 METHOD /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_class.rb:105
c:0009 p:0017 s:0027 b:0027 l:000026 d:000026 METHOD /home/nono/dev/linuxfr.org/lib/pry_for_console.rb:7
c:0008 p:0210 s:0024 b:0024 l:000650 d:000650 METHOD /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/console.rb:44
c:0007 p:0019 s:0020 b:0020 l:000019 d:000019 METHOD /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/console.rb:8
c:0006 p:0430 s:0016 b:0016 l:000015 d:000015 TOP    /home/nono/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:23
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC  :require
c:0003 p:0061 s:0006 b:0006 l:0012d4 d:000adc EVAL   script/rails:6
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0012d4 d:0012d4 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
script/rails:6:in `<main>'
script/rails:6:in `require'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:23:in `<top (required)>'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/console.rb:8:in `start'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in `start'
/home/nono/dev/linuxfr.org/lib/pry_for_console.rb:7:in `start'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_class.rb:105:in `start'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:175:in `repl'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:175:in `catch'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:177:in `block in repl'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:177:in `loop'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:178:in `block (2 levels) in repl'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:193:in `rep'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:226:in `re'
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/pry-0.9.1/lib/pry/pry_instance.rb:226:in `eval'
(pry):3:in `<main>'
(pry):3:in `auto_link'

-- C level backtrace information -------------------------------------------
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_vm_bugreport+0x72) [0xb7808ee2]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x53967) [0xb76e2967]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_bug+0x3a) [0xb76e2a5a]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x106f84) [0xb7795f84]
[0xb787e40c]
/home/nono/.rvm/gems/ruby-1.9.2-p180/gems/rinku-1.2.0/lib/rinku.so(+0x27ad) [0xb6ca37ad]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164208) [0xb77f3208]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x174c0e) [0xb7803c0e]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x169b52) [0xb77f8b52]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16ef88) [0xb77fdf88]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16f8ec) [0xb77fe8ec]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_f_eval+0xdc) [0xb77fef0c]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x5a918) [0xb76e9918]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164208) [0xb77f3208]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x174c0e) [0xb7803c0e]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x169b52) [0xb77f8b52]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16ef88) [0xb77fdf88]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x17221a) [0xb780121a]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_rescue2+0x169) [0xb76e4f79]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x165505) [0xb77f4505]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x1641ed) [0xb77f31ed]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x174c0e) [0xb7803c0e]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x169b52) [0xb77f8b52]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16ef88) [0xb77fdf88]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x178943) [0xb7807943]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_catch_obj+0xb7) [0xb77f2d87]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x165386) [0xb77f4386]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x164208) [0xb77f3208]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x174c0e) [0xb7803c0e]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x169b52) [0xb77f8b52]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16ef88) [0xb77fdf88]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_iseq_eval+0x15b) [0xb77fe53b]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x58e4f) [0xb76e7e4f]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_require_safe+0x602) [0xb76e9562]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_f_require+0x26) [0xb76e9846]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x1641e3) [0xb77f31e3]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x174c0e) [0xb7803c0e]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x169b52) [0xb77f8b52]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x16ef88) [0xb77fdf88]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(rb_iseq_eval_main+0x1f5) [0xb77fe3b5]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(+0x5622a) [0xb76e522a]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(ruby_exec_node+0x25) [0xb76e5265]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/lib/libruby.so.1.9(ruby_run_node+0x35) [0xb76e6a75]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/bin/ruby(main+0x68) [0x8048748]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0xb74abe37]
/home/nono/.rvm/rubies/ruby-1.9.2-p180/bin/ruby() [0x8048641]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

zsh: abort      rails console

Simplify requiring

Hi @vmg. Great gem! :)

You could simplify the documentation on how to use this gem by mentioning that it can be installed via the Gemfile and required at the same time:

gem 'rinku', :require => 'rails_rinku'

Then it can be used in views without any further ado. 💃

target parameter

undefined method `each_pair' for "target='_blank'":String

on rails 3.2.5

Segmentation fault when passing in a partial `a href` tag

Providing the auto_link method with a partial a href tag (possibly due to a truncated string) causes a segmentation fault.

e.g.

> Rinku.auto_link("<a href='http://github.com/'>gith...")
(irb):1: [BUG] Segmentation fault
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin12.4.0]

Abort trap: 6

Way to link URLs with no http:// or www.

Nice job on this library. I'm wondering if there is a config option I'm missing or something to convert URLs without a leading http:// or www.

For example, convert

Let's go to google.com

to

Let's go to <a href="http://google.com">google.com</a>

autolinking <url>

So this is an interesting test case. At the moment rinku does not match the behavior of rails auto_link but rails auto_link also does not produce the result I desire.

Given:

"Some text with an embedded url like this <http://github.com> for example"

Rinku auto_link will currently produce:

Rinku.auto_link("Some text with an embedded url like this <http://github.com> for example")
=> "Some text with an embedded url like this <http://github.com> for example"

Rails auto_link (3.0.10) will produce:

ActionView::Base.new.auto_link("Some text with an embedded url like this <http://github.com> for example")
=> "Some text with an embedded url like this <<a href=\"http://github.com\">http://github.com</a>&gt; for example"

Personally I don't care for the escape mismatch in the angle brackets. They should either both be escaped or neither should be escaped.

Processes stuck in rinku with 2.0.5

Upgrading from 2.0.4 to 2.0.5 seems to have caused processes to start getting stuck in an infinite loop processing particular inputs. I captured a stack trace of one that seemed to be stuck:

#0  0x00007f51901e2fb4 in utf8proc_next (pos=<synthetic pointer>, str=0x7f5174cbffa0 "https://www.keepright.atの情報をもとにエラー修正") at utf8.c:73
#1  utf8proc_find_space (str=str@entry=0x7f5174cbffa0 "https://www.keepright.atの情報をもとにエラー修正", pos=59, size=size@entry=60) at utf8.c:106
#2  0x00007f51901e19b4 in autolink__url (link=0x7f51964a6770, data=0x7f5174cbffa0 "https://www.keepright.atの情報をもとにエラー修正", pos=5, size=60, flags=<optimised out>)
    at autolink.c:307
#3  0x00007f51901e2199 in rinku_autolink (ob=ob@entry=0x7f516c763070, text=<optimised out>, size=60, mode=mode@entry=AUTOLINK_URLS, flags=flags@entry=0, 
    link_attr=0x7f518b1c2d89 "rel=\"nofollow\"", link_attr@entry=0x7f518b1c2d88 " rel=\"nofollow\"", skip_tags=0x7f51903e5020 <SKIP_TAGS.9475>, link_text_cb=0x0, payload=0x7f51964a6930)
    at rinku.c:218
#4  0x00007f51901e28eb in rb_rinku_autolink (argc=<optimised out>, argv=<optimised out>, self=<optimised out>) at rinku_rb.c:208

Force string

When using autolink for user generated content the content may be nil. This returns an error:

Rinku.auto_link(nil) # => TypeError: wrong argument type nil (expected String)

Maybe the argument could be forced to string with to_s.

Strange behavior with Cyrillic link

It made wrong UTF-8 character processing

"Some page located at http://brandingreen.com/researches/глобальная-проблема-электронных-отх/ "

result is

"Some page located at <a href="http://brandingreen.com/researches/глобальная-проблема-электронны?">http://brandingreen.com/researches/глобальная-проблема-электронны?</a>?-отх/ "

Certain UTF-8 characters are picked up as link ending

Say I have a Unicode link:
https://pl.wikipedia.org/wiki/Komisja_śledcza_do_zbadania_sprawy_zarzutu_nielegalnego_wywierania_wpływu_na_funkcjonariuszy_policji,_służb_specjalnych,_prokuratorów_i_osoby_pełniące_funkcje_w_organach_wymiaru_sprawiedliwości

Characters I get for this string is:

>> content
=> "https://pl.wikipedia.org/wiki/Komisja_śledcza_do_zbadania_sprawy_zarzutu_nielegalnego_wywierania_wpływu_na_funkcjonariuszy_policji,_służb_specjalnych,_prokuratorów_i_osoby_pełniące_funkcje_w_organach_wymiaru_sprawiedliwości"
>> content.encoding
=> #<Encoding:UTF-8>
>> content.bytes
=> [104, 116, 116, 112, 115, 58, 47, 47, 112, 108, 46, 119, 105, 107, 105, 112, 101, 100, 105, 97, 46, 111, 114, 103, 47, 119, 105, 107, 105, 47, 75, 111, 109, 105, 115, 106, 97, 95, 197, 155, 108, 101, 100, 99, 122, 97, 95, 100, 111, 95, 122, 98, 97, 100, 97, 110, 105, 97, 95, 115, 112, 114, 97, 119, 121, 95, 122, 97, 114, 122, 117, 116, 117, 95, 110, 105, 101, 108, 101, 103, 97, 108, 110, 101, 103, 111, 95, 119, 121, 119, 105, 101, 114, 97, 110, 105, 97, 95, 119, 112, 197, 130, 121, 119, 117, 95, 110, 97, 95, 102, 117, 110, 107, 99, 106, 111, 110, 97, 114, 105, 117, 115, 122, 121, 95, 112, 111, 108, 105, 99, 106, 105, 44, 95, 115, 197, 130, 117, 197, 188, 98, 95, 115, 112, 101, 99, 106, 97, 108, 110, 121, 99, 104, 44, 95, 112, 114, 111, 107, 117, 114, 97, 116, 111, 114, 195, 179, 119, 95, 105, 95, 111, 115, 111, 98, 121, 95, 112, 101, 197, 130, 110, 105, 196, 133, 99, 101, 95, 102, 117, 110, 107, 99, 106, 101, 95, 119, 95, 111, 114, 103, 97, 110, 97, 99, 104, 95, 119, 121, 109, 105, 97, 114, 117, 95, 115, 112, 114, 97, 119, 105, 101, 100, 108, 105, 119, 111, 197, 155, 99, 105]
>> content.bytes.map(&:chr)
=> ["h", "t", "t", "p", "s", ":", "/", "/", "p", "l", ".", "w", "i", "k", "i", "p", "e", "d", "i", "a", ".", "o", "r", "g", "/", "w", "i", "k", "i", "/", "K", "o", "m", "i", "s", "j", "a", "_", "\xC5", "\x9B", "l", "e", "d", "c", "z", "a", "_", "d", "o", "_", "z", "b", "a", "d", "a", "n", "i", "a", "_", "s", "p", "r", "a", "w", "y", "_", "z", "a", "r", "z", "u", "t", "u", "_", "n", "i", "e", "l", "e", "g", "a", "l", "n", "e", "g", "o", "_", "w", "y", "w", "i", "e", "r", "a", "n", "i", "a", "_", "w", "p", "\xC5", "\x82", "y", "w", "u", "_", "n", "a", "_", "f", "u", "n", "k", "c", "j", "o", "n", "a", "r", "i", "u", "s", "z", "y", "_", "p", "o", "l", "i", "c", "j", "i", ",", "_", "s", "\xC5", "\x82", "u", "\xC5", "\xBC", "b", "_", "s", "p", "e", "c", "j", "a", "l", "n", "y", "c", "h", ",", "_", "p", "r", "o", "k", "u", "r", "a", "t", "o", "r", "\xC3", "\xB3", "w", "_", "i", "_", "o", "s", "o", "b", "y", "_", "p", "e", "\xC5", "\x82", "n", "i", "\xC4", "\x85", "c", "e", "_", "f", "u", "n", "k", "c", "j", "e", "_", "w", "_", "o", "r", "g", "a", "n", "a", "c", "h", "_", "w", "y", "m", "i", "a", "r", "u", "_", "s", "p", "r", "a", "w", "i", "e", "d", "l", "i", "w", "o", "\xC5", "\x9B", "c", "i"]

"ą" character here is split in two bytes: ["\xC4", "\x85"]. \x85 is a new-line character in UTF-8, so I assume that it's interpreted as such, rather than a part of multi-byte sequence.


Maybe #39 is connected?

Apostrophe becoming &#x27;

The excerpt below shows what I think is relevant about my env, and the apostrophe is causing me problems in my application after using auto_link. See below... Please let me know if you need more info.

=== starts without Rinku being required in the env

Loading development environment (Rails 3.2.13)
1.9.3p392 :001 > auto_link("i'm troublesome")
NoMethodError: undefined method `auto_link' for main:Object
    from (irb):1
    from /home/rubysoccer/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /home/rubysoccer/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /home/rubysoccer/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
1.9.3p392 :002 >  include ActionView::Helpers::TextHelper
 => Object 
1.9.3p392 :003 > auto_link("i'm troublesome")
NoMethodError: undefined method `auto_link' for main:Object
    from (irb):3
    from /home/rubysoccer/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /home/rubysoccer/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /home/rubysoccer/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
1.9.3p392 :004 > require 'rails_rinku'
 => true 
1.9.3p392 :005 > auto_link("i'm troublesome")
 => "i&#x27;m troublesome" 
1.9.3p392 :006 > Rinku.auto_link("i'm troublesome")
 => "i'm troublesome" 
1.9.3p392 :007 > 

Support for tel?

Any change that you could add support for telephone numbers using tel:?

JRuby support

Would you be opposed to including equivalent extension code for JRuby? The port should be pretty straightforward: I have done similar for other small extensions like Psych and the code can be nearly a 1:1 match.

rinku is a direct dependency of Discourse, which we would like to support on JRuby.

tag_options error on Rails 5.1.1

I've not dug into it yet, but I suspect that tag_options has been deprecated. I'm getting undefined method 'tag_options' for #<#<Class:0x007f8d2d15d3c8>:0x007f8d2d2f6e00> inside auto_link after upgrading from rails 5.0. This is rinku 2.0.2.

push v1.7.3 tag to GitHub

When you tag releases, would you mind pushing the tags to GitHub? For example the latest version on Rubygems.org is 1.7.3, but the v1.7.3 tag is missing from the repository.

Rinku slices UTF-8 NO-BREAK SPACE to pieces

NO-BREAK SPACE is Unicode code point A0. In UTF-8, it's encoded as C2 A0. When those bytes come at the end of a URL, Rinku is chopping them up, making the C2 part of the URL and the A0 part of text after the link, resulting in illegal UTF-8.

Rinku.auto_link("http://google.com/\xC2\xA0")
# => "<a href=\"http://google.com/\xC2\">http://google.com/\xC2</a>\xA0"

Oddly, this does not happen with INVERTED EXCLAMATION MARK, the very next Unicode code point (A1):

Rinku.auto_link("http://google.com/\xC2\xA1")
# => "<a href=\"http://google.com/¡\">http://google.com/¡</a>"

Here, Runku has included the INVERTED EXCLAMATION MARK as part of the URL. I think it would be better logic to parse it as being after the URL—but regardless, it doesn't split the bytes apart.


This is environment dependent. I'm running Ruby 2.0.0-p353. I'm running the same version on Heroku, where I don't see this issue:

Rinku.auto_link("http://google.com/\xC2\xA0")
# => "<a href=\"http://google.com/ \">http://google.com/ </a>"

Allow setting the global default skip_tags value

It'd be nice if we could change the default skip_tags array to something other than %w[a pre code kbd script] on a global basis. Pretty sure we'll want the same value everywhere we use auto_link.

Unspecified encoding for gemspec file causes encoding problems with passenger spawner under ruby 1.9.2

The default passenger ruby wrapper wraps ruby as

exec ruby -E ASCII-8BIT "$@"

which causes problem with the multibyte character in the gemspec author field.

A simple encoding hint at the top of the gemspec (# encoding: UTF-8) seems to solve it.

Sample trace below:


from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/message_channel.rb:287:in `write_scalar'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:330:in `send_error_page'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:297:in `rescue in handle_spawn_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:274:in `handle_spawn_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/helper-scripts/passenger-spawn-server:99:in `<main>'
[ pid=3573 thr=67894760 file=utils.rb:176 time=2011-11-10 23:32:27.986 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner (/var/www/myapp/app/shared/bundle/ruby/1.9.1/bundler/gems/rinku-60f821316be1/rinku.gemspec:11: invalid multibyte char (US-ASCII)
                                                                                                                         /var/www/myapp/app/shared/bundle/ruby/1.9.1/bundler/gems/rinku-60f821316be1/rinku.gemspec:11: invalid multibyte char (US-ASCII)
                                                                                                                         /var/www/myapp/app/shared/bundle/ruby/1.9.1/bundler/gems/rinku-60f821316be1/rinku.gemspec:11: syntax error, unexpected $end, expecting ']'
s.authors = ["Vicent Martí"]
^) (process 3573, thread #<Thread:0x817fbd0>):
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler.rb:241:in `eval'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler.rb:241:in `rescue in block in load_gemspec'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler.rb:236:in `block in load_gemspec'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler.rb:234:in `chdir'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler.rb:234:in `load_gemspec'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/source.rb:353:in `block in load_spec_files'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/source.rb:352:in `each'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/source.rb:352:in `load_spec_files'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/source.rb:570:in `load_spec_files'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/source.rb:385:in `local_specs'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/source.rb:555:in `specs'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/lazy_specification.rb:48:in `__materialize__'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/spec_set.rb:84:in `block in materialize'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/spec_set.rb:82:in `map!'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/spec_set.rb:82:in `materialize'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/definition.rb:90:in `specs'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/definition.rb:135:in `specs_for'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/definition.rb:124:in `requested_specs'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/environment.rb:23:in `requested_specs'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler/runtime.rb:11:in `setup'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21.rc/lib/bundler.rb:110:in `setup'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/utils.rb:326:in `prepare_app_process'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:155:in `block in initialize_server'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/utils.rb:572:in `report_app_init_status'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:153:in `initialize_server'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:204:in `start_synchronously'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/rack/application_spawner.rb:128:in `start'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
from <internal:prelude>:10:in `synchronize'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/helper-scripts/passenger-spawn-server:99:in `<main>'
*** Exception Encoding::CompatibilityError in spawn manager (incompatible character encodings: ASCII-8BIT and US-ASCII) (process 3573, thread #<Thread:0x817fbd0>):
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/message_channel.rb:287:in `write_scalar'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:330:in `send_error_page'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:297:in `rescue in handle_spawn_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb:274:in `handle_spawn_application'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /home/passenger/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/helper-scripts/passenger-spawn-server:99:in `<main>'

´´´

invalid byte sequence in UTF-8

$ rails -v
Rails 4.0.0

$ ruby -v
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin11.4.2]

$ cat Gemfile.lock | grep rinku
  remote: https://github.com/vmg/rinku.git
    rinku (1.7.3)
  rinku!

it seems to give invalid byte sequence error when any multibyte chars are followed after a linkable email address without a space between.

# in rails c
helper.auto_link "[email protected]あ"

this will return

"<a href=\"mailto:[email protected]\xE3\">[email protected]\xE3</a>\x81\x82"

instead of

"<a href=\"mailto:[email protected]\">[email protected]</a>あ"

Quoted URLs include the closing quote when auto linked

Example:

text = 'some text "http://example.com/" some text'
=> "some text \"http://example.com/\" some text"

 Rinku.auto_link(text, :all)
=> "some text  \"<a href=\"http://example.com/&quot;\">http://example.com/\"</a> some text"

The href http://example.com/&quot; is incorrect here.

Related to #46 ?

A way to whitelist/blacklist/test URL patterns to link?

I'm working on a project that auto links URLs in user comments. It works great, but occasionally we get a decent amount of link spam. They're valid posts from valid users, they're just not in line with the community guidelines.

Since these forums are highly topical, I'd love a way to pass a whitelist of acceptable domains, or a regex pattern, so URLs to domains related to the relevant products get linked, but not random stuff. That way we don't aggravate users by blocking their posts, but also de-incentivize the SEO spam.

Is there a way to do that with rinku? I'd rather not fall back on regex'ing the text myself.

Can't compile 2.0.0 on windows

there was no problem with the previous version 1.7.3

C:\Ruby21-x64\devkit>gem update rinku
Updating installed gems
Updating rinku
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rinku:
ERROR: Failed to build gem native extension.

C:/Ruby21-x64/bin/ruby.exe extconf.rb

creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
generating rinku-x64-mingw32.def
0 [main] sh 4768 fork_copy: linked dll data/bss pass 0 failed, 0x6E8000..0x6E8AD8, done 0, windows pid 256, Win32 error 487
/bin/sh: fork: Resource temporarily unavailable
make: *** [rinku-x64-mingw32.def] Error 128

make failed, exit code 2

Automatically add utm_source and utm_medium

Hi Vicent, I love Rinku but I need a feature that it doesnt have yet: I wanted to automatically add utm_source and utm_medium parameters in some cases.

I have a social network and wanted that when a user posts links on comments and messages, Rinku automatically added those parameters to the URLs so when I bring visits to another site, they easily know where those visitors came from.

Should I make a pull request or fork it and do my own version with this feature?

wrong argument type nil (expected String) when string begins with "www."

I've been using Rinku for several months, and just recently, a problem popped up that I had not seen before. I'm using Rinku on a particular text field which may or may not contain a URL. All this time, the URLs have always started with http://, but recently, a user of this particular web application entered www.hostname.tld, and Rinku.auto_link started throwing exceptions:

wrong argument type nil (expected String)
  vendor/bundle/ruby/1.9.1/gems/rinku-1.5.1/lib/rails_rinku.rb:16:in `auto_link'

When I modified the string to start with http:// or removed www., the problem went away.

Curly quotes should not be part of URL

Rinku.auto_link(%(‘http://example.org’)) produces ‘<a href="http://example.org’">http://example.org’</a>. I would have expected it to produce ‘<a href="http://example.org">http://example.org</a>’ instead. Similarly for Rinku.auto_link(%(“http://example.org”)).

These curly quotes should probably be treated the same as their straight cousins ' and ", right?

Extract_URLs method

Hello guys,

I want suggest a thing that can improve a lot the "Rinku" gem. I try to find this in this gem, but I think it doesn't exist yet.

What you think about add a method to extract urls, like Twitter-Text gem does with "extract_urls"? It will be very useful and can increment the usage of this gem.

Thanks for attention,
A hug, Fernando P.

Autolinking fails with Rails localhost links

Rinku does not autolink localhost links used by Rails in :development mode.

irb(main):010:0> Rinku.auto_link("http://localhost:3000/products")
=> "http://localhost:3000/products"

While this URL might be missing a TLD, it's still weird that Rinku skips it. I actually thought Rinku was broken, but it turns out it was just ignoring my localhost links.

As a result, I believe my autolinking code will work in production -- where the URLs generated by the router will inherit the top-level domain from the production site -- but continue to fail in development and testing.

Ideally, for the sake of consistency, it should work in all three environments.

How to open web links in a separate window, but not email links?

Hi!

I use Rinku to auto_link my markdown, and it works great! Thanks!

I use Rinku like this

Rinku.auto_link text, :all, 'target="_blank"'

This opens the links in a new window. Excellent! However, it also opens a new window for all email links, and that is very annoying. Is there a way to avoid opening email links in a new window?

Cannot find such file rinku.so

rinku is being installed in my app as a dependency of wikicloth gem. However when I run my application, it says:

`require': cannot load such file -- rinku.so (LoadError)

I opened the gem and could not find any such file either. What is the issue?

Seg fault on less than symbols

ree-1.8.7-2010.02 > Rinku.auto_link "I ate 3-4 of these in < 2 weeks."
(irb):1: [BUG] Segmentation fault
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02

should html_safe? html safety marker be preserved?

Rails uses an html_safe marker to indicate if the string is properly HTML-safe.

If rinku doesn't do a substitution, it just returns the input, the identical object, so of course HTML safety marker is unchanged.

input_s = "<b>bold</b>".html_safe
input_s.html_safe? # => true

output_s = Rinku.auto_link(input_s)
onput_s.html_safe? # => true

But if rinku actually does a substitution, it always returns a string without html_safe set.

html_input = "<b>bold</b> http://example.com".html_safe
html_input.html_safe?

html_output = Rinku.auto_link(html_input)
# =-> "<b>bold</b> <a href=\"http://example.com\">http://example.com</a>"
html_output.html_safe? # => false

If rinku is performing correctly without bugs, then the input in fact should still be html_safe if the input was.

Should rinku set html_safe on output in cases where html_safe was set on input?

Without this, when using with html input (as Rinku specifically supports), users will often just need to add it on themselves Rinku.auto_link(html_input).html_safe. This is both wordier/repetitive and somewhat more subject to error, you might accidentally set html_safe even when the input didn't already have html_safe set, which could open you up to XSS bugs; really the logic should be setting html_safe on output only if it was set on input.

Trailing non-breaking space included in link

If an input string contains a non-breaking space (&nbsp;) immediately after a URL, the non-breaking space and the next word are included in the link.

For example, this string works: http://example.com test. (It becomes <a href="http://example.com/">http://example.com/</a> test.)

However, this string does not work: http://example.com/&nbsp;test. (It becomes <a href="http://example.com/&nbsp;test\">http://example.com/&nbsp;test</a>.)

This also affects strings containing a closing bracket (parenthesis, square bracket, or curly bracket) between the URL and the non-breaking space. For example: website (http://example.com/)&nbsp;of the user becomes website (<a href="http://example.com/)&nbsp;of\">http://example.com/)&nbsp;of</a> the user.

Markdown-style links gobble up subsequent word

This seems like a bug:

Rinku.auto_link("[Bing](http://bing.com) is my favorite search engine")
=> "[Bing](<a href=\"http://bing.com) is\">http://bing.com) is</a> my favorite search engine"

I'd've expected

"[Bing](<a href=\"http://bing.com)\">http://bing.com</a>) is my favorite search engine"

broken on rbx2

An exception occurred running /Users/test/.rbenv/versions/rbx-2.0.0-rc1/lib/bin/irb.rb
    Out-of-date or not compatible. Recompile or reinstall gem (rbx-2.0.0-rc1/rbx/1.8/gems/rinku-1.7.2/ext/rinku/rinku.bundle) (LoadError::InvalidExtensionError)

Backtrace:
          Rubinius::NativeMethod.load_extension at kernel/common/native_method.rb:34
              Rubinius::CodeLoader#load_library at kernel/delta/codeloader.rb:198
                   Rubinius::CodeLoader#require at kernel/common/codeloader.rb:131
                   Rubinius::CodeLoader.require at kernel/common/codeloader.rb:206
  Kernel(Module)#gem_original_require (require) at kernel/common/kernel.rb:631

The offending code in rbx is:

 31       ver = lib.find_symbol("__X_rubinius_version")
 32 
 33       unless ver
 34         raise LoadError::InvalidExtensionError, "Out-of-date or not compatible. Recompile or reinstall gem (#{library})"
 35       end

This is likely due to the $CFLAGS += ' -fvisibility=hidden' in extconf.rb

Underscores in subdomains break autolinking

Opened from an internal issue (gh#106307) — cmark-gfm's autolinker will happily autolink subdomains with underscores in them. Live example:

https://abc_def.google.com

Rinku does not, and this disparity can cause confusion at times. Underscores aren't "meant" to be in domain names but subdomains with them do resolve and so are valid by use. Rinku should support this.

Note that this does not extend to underscores in the registrable domain:

https://abc_def.com

This is not valid, and Rinku and cmark-gfm both correctly disallow it. This should be maintained in the face of a fix.

Rinku should assume HTML encoded input

I'm seeing a lot of issues that seem to stem from Rinku trying to detect whether input is HTML encoded or not. #6 is one example.

Here's another:

>> Rinku.auto_link("This text is HTML encoded: http://example.com?x=1&amp;y=2")
=> "This text is HTML encoded: <a href=\"http://example.com?x=1&amp;amp;y=2\">http://example.com?x=1&amp;amp;y=2</a>"

It's actually responsible for mangling the real text in this comment even. Here's the actual text I pasted:

https://gist.github.com/846f567ad158730811a2

Input into Rinku should always be HTML encoded. Why is it re-encoding in all these circumstances?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.