Skip to content

Commit

Permalink
add validity check to hashes wikification syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
cotto committed Aug 25, 2010
1 parent 7f35256 commit 6ce3f7a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion github/github.py
Expand Up @@ -121,7 +121,7 @@ def _format_changeset_link(self, formatter, rev_type, ns, match):
if rev_type == 'svn':
svn_rev = match.group(0).replace('r','',1)
git_hash = self._get_git_hash(svn_rev)
if git_hash:
if self._git_hash_is_valid(git_hash):
title = shorten_line(self._get_git_title(git_hash))
return tag.a(match.group(0), href="%s/%s" % (formatter.href.changeset(), git_hash),
title=title, class_="changeset")
Expand Down Expand Up @@ -171,6 +171,14 @@ def _get_git_hash(self, svn_rev):
return row[0]
return None

def _git_hash_is_valid(self, git_hash):
cursor = self.env.get_db_cnx().cursor()
row = cursor.execute("SELECT 1 FROM svn_revmap WHERE git_hash LIKE '%s%%';" % git_hash).fetchone()
if row:
return True
self.env.log.debug("REJECTED HASH '%s'", git_hash)
return False

def _get_git_title(self, git_hash):
#TODO: working code
return "um... tooltip?"
Expand Down

0 comments on commit 6ce3f7a

Please sign in to comment.