From 4da1d589f539b9f650aee2735e81a93e543d1fa3 Mon Sep 17 00:00:00 2001
From: Alex Shulgin <ash@commandprompt.com>
Date: Wed, 10 Aug 2011 10:25:20 +0300
Subject: [PATCH 07/25] Preserve leading zeros in #nnn issue links.

Sometimes a user would post an issue containing something like
"#01234" in the description/update.  If there happen to be an issue
with that number (and it is visible by the current user, which is
always true for site admin,) the text would be converted to a link
"#1234" w/o the leading zero when rendering the issue on the web.
This was a problem when a user didn't mean to refer to an issue
numbered 1234, but was using it in some other environment-specific
context.
---
 app/helpers/application_helper.rb |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 9cf167f..58e7a03 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -697,7 +697,9 @@ module ApplicationHelper
           when nil
             if issue = Issue.visible.find_by_id(oid, :include => :status)
               anchor = comment_id ? "note-#{comment_id}" : nil
-              link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
+              # Use pristine identifier instead of oid to preserve any
+              # leading zeros.
+              link = link_to("##{identifier}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
                                         :class => issue.css_classes,
                                         :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
             end
-- 
1.7.0.4

