← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jcsackett/launchpad/linkifier-bugs-2-indexing-error into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/linkifier-bugs-2-indexing-error into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #118284 URLs ending with a ) aren't linkified properly
  https://bugs.launchpad.net/bugs/118284


Summary
=======

A corner case in the handle_parens method introduced an IndexError when dealing with certain patterns of parens. This occured if there were open parens in the URL and no trailer.

Proposed Fix
============

Make certain that the _handle_parens method is only called if trailers is not an empty string.

Implementation
==============

lib/lp/app/browser/stringformatter.py
-------------------------------------

The call site for _handle_parens is moved to inside the conditional clause where trailers are matched; if trailers are empty, the method is not called.

Additionally, an assertion is set on the method to ensure that it's only called with trailers as something other than an empty string.

Tests
=====

bin/test -t stringformatter

QA
==

In launchpad.dev, file a bug or make a bug comment that has only "http://example.com/path_(with_parens"

It should linkify, and shouldn't cause any error.
-- 
https://code.launchpad.net/~jcsackett/launchpad/linkifier-bugs-2-indexing-error/+merge/44240
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/linkifier-bugs-2-indexing-error into lp:launchpad.