From 79eb882a31558dd5a2c6ab74ef652178860931cb Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Thu, 9 Jun 2005 20:24:14 +0000 Subject: [PATCH] Avoid autolinking Markdown URIs (ticket:177) --- app/models/chunks/uri.rb | 2 +- app/models/wiki_content.rb | 4 +++- test/unit/revision_test.rb | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/models/chunks/uri.rb b/app/models/chunks/uri.rb index 8280ee8c..1a208535 100644 --- a/app/models/chunks/uri.rb +++ b/app/models/chunks/uri.rb @@ -71,7 +71,7 @@ class URIChunk < Chunk::Abstract '(?=\.?(?:\s|\)|\z))' # ends only with optional dot + space or ")" # or end of the string - SUSPICIOUS_PRECEDING_CHARACTER = '(!|\"\:|\"|\\\')?' # any of !, ":, ", ' + SUSPICIOUS_PRECEDING_CHARACTER = '(!|\"\:|\"|\\\'|\]\()?' # any of !, ":, ", ', ]( INTERNET_URI_REGEXP = Regexp.new(SUSPICIOUS_PRECEDING_CHARACTER + INTERNET_URI, Regexp::EXTENDED, 'N') diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index eaded5b7..e8e766da 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -141,7 +141,9 @@ class WikiContent < String @options[:engine] = Engines::MAP[@web.markup] @options[:engine_opts] = [:filter_html, :filter_styles] if @web.safe_mode @options[:active_chunks] = (ACTIVE_CHUNKS - [WikiChunk::Word] ) if @web.brackets_only - + + @not_rendered = @pre_rendered = nil + super(@revision.content) init_chunk_manager build_chunks diff --git a/test/unit/revision_test.rb b/test/unit/revision_test.rb index 2da78fa7..bd84e660 100755 --- a/test/unit/revision_test.rb +++ b/test/unit/revision_test.rb @@ -72,6 +72,15 @@ class RevisionTest < Test::Unit::TestCase %{return ThatWay\n\n\n

Nice!

}, code_block) end + + def test_markdown_hyperlink_with_slash + # in response to a bug, see http://dev.instiki.org/attachment/ticket/177 + @web.markup = :markdown + + assert_markup_parsed_as( + '

text

', + '[text](http://example/with/slash)') + end def test_mixed_formatting