From 4017e3d8b00dcefb9ba54b7464136ee55c402adc Mon Sep 17 00:00:00 2001 From: Dmitry Bochkarev Date: Fri, 23 Oct 2015 13:15:36 +0500 Subject: [PATCH] =?UTF-8?q?fix(html):=20=D0=BA=D0=B8=D1=80=D0=B8=D0=BB?= =?UTF-8?q?=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D1=81=D1=81?= =?UTF-8?q?=D1=8B=D0=BB=D0=BA=D0=B8=20=D0=B2=20=D1=83=D1=80=D0=BB=D0=B0?= =?UTF-8?q?=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://jira.railsc.ru/browse/SERVICES-594 старая логика заменяла unicode ссылки на представление в URI-encoding: ``` [97] pry(main)> Nokogiri::HTML::DocumentFragment.parse('ссылка').to_s => "ссылка" ``` --- lib/string_tools/html.rb | 41 +++++++++++++++++++++++++++++++++------- spec/html_spec.rb | 18 ++++++++++++++++++ string_tools.gemspec | 3 ++- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/lib/string_tools/html.rb b/lib/string_tools/html.rb index d3d66b9..4cabc40 100644 --- a/lib/string_tools/html.rb +++ b/lib/string_tools/html.rb @@ -1,11 +1,18 @@ # coding: utf-8 -require 'loofah' +require 'nokogiri' require 'addressable/uri' +require 'simpleidn' module StringTools module HTML # минимальная длина строки, в которой могут быть ссылки TEXT_WITH_LINKS_MINIMUM_LENGTH = 'www.фермаежей.рф + www.мояфермаежей.рф + MARKUP + end + + it 'should keep relative links' do + is_expected.to eq(<<-MARKUP) + www.фермаежей.рф + www.мояфермаежей.рф + MARKUP + end + end end end diff --git a/string_tools.gemspec b/string_tools.gemspec index 2f63838..9fedffc 100644 --- a/string_tools.gemspec +++ b/string_tools.gemspec @@ -26,7 +26,8 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'addressable', '~> 2.3.2' spec.add_runtime_dependency 'ru_propisju', '~> 2.1.4' spec.add_runtime_dependency 'sanitize', '>= 3.1.2' - spec.add_runtime_dependency 'loofah', '>= 2.0.0' + spec.add_runtime_dependency 'nokogiri' + spec.add_runtime_dependency 'simpleidn', '>= 0.0.5' spec.add_development_dependency 'bundler', '~> 1.7' spec.add_development_dependency 'rake', '~> 10.0'