https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292020-02-17T06:59:02ZRedmineRedmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=962862020-02-17T06:59:02ZYuichi HARADA
<ul><li><strong>File</strong> <a href="/attachments/24835">32971-fixed.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/24835/32971-fixed.patch">32971-fixed.patch</a> added</li></ul><p>I think the behavior has probably changed by applying <a class="changeset" title="\f or \v character in Textile markup may cause RegexpError exception (#29756). Patch by Go MAEDA." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17603">r17603</a> ( <a href="https://www.redmine.org/issues/29756" class="external">Defect !#29756: \f or \v character in Textile markup may cause RegexpError exception</a> ).</p>
<p><a class="external" href="https://www.redmine.org/projects/redmine/repository/revisions/17603/diff/trunk/lib/redmine/wiki_formatting/textile/redcloth3.rb">https://www.redmine.org/projects/redmine/repository/revisions/17603/diff/trunk/lib/redmine/wiki_formatting/textile/redcloth3.rb</a></p>
<p>It could be resolved with the following patch.</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 80e0a3626..ff4687f7e 100644
</span><span class="gd">--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
</span><span class="gi">+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
</span><span class="p">@@ -1020,10 +1020,13 @@</span> class RedCloth3 < String
end
def flush_left( text )
<span class="gd">- indt = 0
- if text =~ /^ /
</span><span class="gi">+ if /(?![\r\n\t ])[[:cntrl:]]/.match?(text)
+ text.gsub!(/(?![\r\n\t ])[[:cntrl:]]/, '')
+ end
+ if /^ /.match?(text) && text.length > 1
+ indt = 0
</span> unless text.empty?
<span class="gd">- indt += 1 while text !~ /^ {#{indt}}[^ ]/
</span><span class="gi">+ indt += 1 while text !~ /^ {#{indt}}\S/
</span> end
if indt.nonzero?
text.gsub!( /^ {#{indt}}/, '' )
</code></pre> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963012020-02-18T04:41:47ZJihyeon Gim
<ul></ul><p>Thanks for your help Yuichi! :)</p>
<p>This patch works gracefully well!</p>
<p>Thank you again for patching it :)</p> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963092020-02-18T12:18:50ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/29756">Defect #29756</a>: \f or \v character in Textile markup may cause RegexpError exception</i> added</li></ul> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963112020-02-18T12:19:40ZGo MAEDA
<ul><li><strong>Target version</strong> set to <i>Candidate for next minor release</i></li></ul> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963172020-02-19T02:47:58ZYuichi HARADA
<ul><li><strong>File</strong> <i>32971-fixed-v2.patch</i> added</li></ul><p>Yuichi HARADA wrote:</p>
<blockquote>
<p>I think the behavior has probably changed by applying <a class="changeset" title="\f or \v character in Textile markup may cause RegexpError exception (#29756). Patch by Go MAEDA." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17603">r17603</a> ( <a href="https://www.redmine.org/issues/29756" class="external">Defect !#29756: \f or \v character in Textile markup may cause RegexpError exception</a> ).</p>
<p><a class="external" href="https://www.redmine.org/projects/redmine/repository/revisions/17603/diff/trunk/lib/redmine/wiki_formatting/textile/redcloth3.rb">https://www.redmine.org/projects/redmine/repository/revisions/17603/diff/trunk/lib/redmine/wiki_formatting/textile/redcloth3.rb</a></p>
<p>It could be resolved with the following patch.</p>
<p>[...]</p>
</blockquote>
<p>Sorry, I found that <code>String#lstrip!</code> could do the same.</p>
<p><a class="external" href="https://www.rubydoc.info/stdlib/core/String#lstrip!-instance_method">https://www.rubydoc.info/stdlib/core/String#lstrip!-instance_method</a></p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 80e0a3626..815f860e6 100644
</span><span class="gd">--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
</span><span class="gi">+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
</span><span class="p">@@ -1020,15 +1020,7 @@</span> class RedCloth3 < String
end
def flush_left( text )
<span class="gd">- indt = 0
- if text =~ /^ /
- unless text.empty?
- indt += 1 while text !~ /^ {#{indt}}[^ ]/
- end
- if indt.nonzero?
- text.gsub!( /^ {#{indt}}/, '' )
- end
- end
</span><span class="gi">+ text&.lstrip!
</span> end
def footnote_ref( text )
</code></pre> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963182020-02-19T04:18:23ZYuichi HARADA
<ul></ul><p>Yuichi HARADA wrote:</p>
<blockquote>
<p>Yuichi HARADA wrote:</p>
<blockquote>
<p>I think the behavior has probably changed by applying <a class="changeset" title="\f or \v character in Textile markup may cause RegexpError exception (#29756). Patch by Go MAEDA." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/17603">r17603</a> ( <a href="https://www.redmine.org/issues/29756" class="external">Defect !#29756: \f or \v character in Textile markup may cause RegexpError exception</a> ).</p>
<p><a class="external" href="https://www.redmine.org/projects/redmine/repository/revisions/17603/diff/trunk/lib/redmine/wiki_formatting/textile/redcloth3.rb">https://www.redmine.org/projects/redmine/repository/revisions/17603/diff/trunk/lib/redmine/wiki_formatting/textile/redcloth3.rb</a></p>
<p>It could be resolved with the following patch.</p>
<p>[...]</p>
</blockquote>
<p>Sorry, I found that <code>String#lstrip!</code> could do the same.</p>
<p><a class="external" href="https://www.rubydoc.info/stdlib/core/String#lstrip!-instance_method">https://www.rubydoc.info/stdlib/core/String#lstrip!-instance_method</a></p>
<p>[...]</p>
</blockquote>
<p>It did not work well with attachment:32971-fixed-v2.patch . The same problem occurred as in the previous situation.<br />Please delete attachment:32971-fixed-v2.patch .</p> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963192020-02-19T04:42:07ZGo MAEDA
<ul><li><strong>File</strong> deleted (<del><i>32971-fixed-v2.patch</i></del>)</li></ul> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963272020-02-19T06:17:27ZYuichi HARADA
<ul><li><strong>File</strong> <a href="/attachments/24857">32971-fixed-v3.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/24857/32971-fixed-v3.patch">32971-fixed-v3.patch</a> added</li></ul><p>I fixed the <a class="attachment" href="https://www.redmine.org/attachments/24835">32971-fixed.patch</a> because sometimes the <code>flush_left</code> method did not end.</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 80e0a3626..c9bdd0aeb 100644
</span><span class="gd">--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
</span><span class="gi">+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
</span><span class="p">@@ -1020,11 +1020,12 @@</span> class RedCloth3 < String
end
def flush_left( text )
<span class="gd">- indt = 0
- if text =~ /^ /
- unless text.empty?
- indt += 1 while text !~ /^ {#{indt}}[^ ]/
- end
</span><span class="gi">+ if /(?![\r\n\t ])[[:cntrl:]]/.match?(text)
+ text.gsub!(/(?![\r\n\t ])[[:cntrl:]]/, '')
+ end
+ if /^ +\S/.match?(text)
+ indt = 0
+ indt += 1 while !/^ {#{indt}}\S/.match?(text)
</span> if indt.nonzero?
text.gsub!( /^ {#{indt}}/, '' )
end
</code></pre> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963422020-02-19T10:40:44ZKevin Fischer
<ul></ul><p>How about adding a unit test to prevent future regressions of this conversion?</p> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963542020-02-20T03:10:41ZYuichi HARADA
<ul></ul><p>Ji-Hyeon Gim wrote:</p>
<blockquote>
<p>New line between list items break a list when I try to write ordered/unordered list with textile.</p>
<ul>
<li>Example<br /><pre>
* list1
* list2
* list3
# list4
# list5
# list6
</pre></li>
</ul>
<ul>
<li>In 3.2.1<br /><img src="https://www.redmine.org/attachments/download/24780/3.2.1.png" alt="" /></li>
</ul>
</blockquote>
<p>I noticed when looking at <a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb#L148">source:trunk/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb#L148</a> that this nested list is probably wrong for Textile.</p>
<pre><code class="ruby syntaxhl"> <span class="k">def</span> <span class="nf">test_nested_lists</span>
<span class="n">raw</span> <span class="o">=</span> <span class="o"><<~</span><span class="no">RAW</span><span class="sh">
# Item 1
# Item 2
** Item 2a
** Item 2b
# Item 3
** Item 3a
</span><span class="no"> RAW</span>
<span class="n">expected</span> <span class="o">=</span> <span class="o"><<~</span><span class="no">EXPECTED</span><span class="sh">
<ol>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Item 2a</li>
<li>Item 2b</li>
</ul>
</li>
<li>Item 3
<ul>
<li>Item 3a</li>
</ul>
</li>
</ol>
</span><span class="no"> EXPECTED</span>
<span class="n">assert_equal</span> <span class="n">expected</span><span class="p">.</span><span class="nf">gsub</span><span class="p">(</span><span class="sr">%r{</span><span class="se">\s</span><span class="sr">+}</span><span class="p">,</span> <span class="s1">''</span><span class="p">),</span> <span class="n">to_html</span><span class="p">(</span><span class="n">raw</span><span class="p">).</span><span class="nf">gsub</span><span class="p">(</span><span class="sr">%r{</span><span class="se">\s</span><span class="sr">+}</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span>
<span class="k">end</span>
</code></pre> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=963612020-02-20T08:02:02ZYuichi HARADA
<ul><li><strong>File</strong> <a href="/attachments/24865">32971-fixed-v4.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/24865/32971-fixed-v4.patch">32971-fixed-v4.patch</a> added</li></ul><p>Kevin Fischer wrote:</p>
<blockquote>
<p>How about adding a unit test to prevent future regressions of this conversion?</p>
</blockquote>
<p>Thank you for pointing it out.<br />I have added the following test to <a class="attachment" href="https://www.redmine.org/attachments/24857">32971-fixed-v3.patch</a> .</p>
<pre><code class="diff syntaxhl"><span class="gh">diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
index 19128524e..2358ded58 100644
</span><span class="gd">--- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
</span><span class="gi">+++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
</span><span class="p">@@ -171,6 +171,24 @@</span> class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
</ol>
EXPECTED
assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
<span class="gi">+
+ raw = <<~RAW
+ * Item-1
+
+ * Item-1a
+ * Item-1b
+ RAW
+ expected = <<~EXPECTED
+ <ul>
+ <li>Item-1
+ <ul>
+ <li>Item-1a</li>
+ <li>Item-1b</li>
+ </ul>
+ </li>
+ </ul>
+ EXPECTED
+ assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '')
</span> end
def test_escaping
</code></pre> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=964162020-02-25T02:22:39ZKevin Fischer
<ul></ul><p>Tried it out. The test passed, so looks good to me!</p> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=964382020-02-26T16:51:51ZGo MAEDA
<ul><li><strong>Target version</strong> changed from <i>Candidate for next minor release</i> to <i>4.1.1</i></li></ul><p>Setting the target version to 4.1.1.</p> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=964652020-02-29T04:22:17ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>Go MAEDA</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Committed the patch. Thank you.</p> Redmine - Defect #32971: New line between list items break a listhttps://www.redmine.org/issues/32971?journal_id=964882020-02-29T14:37:59ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li></ul>