Skip to content

Commit

Permalink
Fixed an error that occurred when a link was badly nested in parenthe…
Browse files Browse the repository at this point in the history
…ses.

The error is fixed, but the mis-recognition of the badly written link is still a problem. [jgarber#55 state:open]
  • Loading branch information
jgarber committed Sep 22, 2008
1 parent 3ca59c9 commit b02f629
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -12,6 +12,8 @@

* Fixed compatibility issues with Ruby 1.9 [Keita Yamaguchi]. #52, 53, 54

* Fixed an error when a link was badly nested in parentheses. #55


*4.0.3 (August 18, 2008)*

Expand Down
10 changes: 10 additions & 0 deletions ext/redcloth_scan/redcloth_scan.rl
Expand Up @@ -395,6 +395,9 @@ redcloth_html_esc(int argc, VALUE* argv, VALUE self) //(self, str, level)
rb_scan_args(argc, argv, "11", &str, &level);

VALUE new_str = rb_str_new2("");
if (str == Qnil)
return new_str;

StringValue(str);

if (RSTRING_LEN(str) == 0)
Expand Down Expand Up @@ -450,8 +453,15 @@ static VALUE
redcloth_latex_esc(VALUE self, VALUE str)
{
VALUE new_str = rb_str_new2("");

if (str == Qnil)
return new_str;

StringValue(str);

if (RSTRING_LEN(str) == 0)
return new_str;

char *ts = RSTRING_PTR(str), *te = RSTRING_PTR(str) + RSTRING_LEN(str);
char *t = ts, *t2 = ts, *ch = NULL;
if (te <= ts) return;
Expand Down
9 changes: 9 additions & 0 deletions test/test_formatters.rb
Expand Up @@ -8,8 +8,17 @@ class TestFormatters < Test::Unit::TestCase
RedCloth.new(doc['in']).to_html
end

def test_html_orphan_parenthesis_in_link_can_be_followed_by_punctuation_and_words
assert_nothing_raised { RedCloth.new(%Q{Test "(read this":http://test.host), ok}).to_html }
end

generate_formatter_tests('latex') do |doc|
RedCloth.new(doc['in']).to_latex
end

def test_latex_orphan_parenthesis_in_link_can_be_followed_by_punctuation_and_words
assert_nothing_raised { RedCloth.new(%Q{Test "(read this":http://test.host), ok}).to_latex }
end


end

0 comments on commit b02f629

Please sign in to comment.