diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8473e9f2a..cdec8a25a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -45,5 +45,5 @@ submit the change with your pull request. - Marlena Compton / [Marlena](https://github.com/marlena) - Elizabeth A. Kari / [catfriend](https://github.com/catfriend) - Cheri Allen / [cherimarie](https://github.com/cherimarie) -- Shiho Takagi / [oshiho3](https:://github.com/oshiho3) - Maki Sugita / [macckii](https:://github.com/macckii) +- Shiho Takagi / [oshiho3](https://github.com/oshiho3) diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 32ea66915..365351fac 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -15,6 +15,7 @@ = form_tag(new_photo_path, :method => :get, :class => 'form-inline') do = label_tag :set, "Choose a photo set:", :class => 'control-label' = select_tag :set, options_for_select(@sets, @current_set), :class => 'input-large' + = hidden_field_tag :planting_id, @planting_id = submit_tag "Search", :class => 'btn btn-primary' %div.pagination diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb index 35333a256..7069590e7 100644 --- a/lib/haml/filters/growstuff_markdown.rb +++ b/lib/haml/filters/growstuff_markdown.rb @@ -7,7 +7,7 @@ module Haml::Filters def render(text) # turn [tomato](crop) into [tomato](http://growstuff.org/crops/tomato) - expanded = text.gsub(/\[(.*?)\]\(crop\)/) do |m| + expanded = text.gsub(/\[([^\[\]]+?)\]\(crop\)/) do |m| crop_str = $1 # find crop case-insensitively crop = Crop.where('lower(name) = ?', crop_str.downcase).first diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 566740307..718645322 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -52,4 +52,12 @@ describe 'Haml::Filters::Growstuff_Markdown' do rendered.should match /#{output_link(@crop, 'ToMaTo')}/ end + it "fixes PT bug #78615258 (Markdown rendering bug with URLs and crops in same text)" do + tomato = FactoryGirl.create(:tomato) + string = "[test](http://example.com) [tomato](crop)" + rendered = Haml::Filters::GrowstuffMarkdown.render(string) + rendered.should match /#{output_link(tomato)}/ + rendered.should match "test" + end + end