James Moger
2012-07-11 2b67ec0e4a42ad1069a477040a549c3e19be9e36
Fix for line number identification bug in LuceneExecutor (issue-105)
2 files modified
13 ■■■■■ changed files
docs/04_releases.mkd 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/LuceneExecutor.java 12 ●●●●● patch | view | raw | blame | history
docs/04_releases.mkd
@@ -6,6 +6,7 @@
#### fixes
- Fixed intermittent bug in identifying line numbers in Lucene search (issue 105)
- Adjust repository search to handle foo.git and foo/bar.git (issue 104)
- Fixed bug where a repository set as authenticated push did not have anonymous clone access (issue 96)
- Fixed bug in Basic authentication if passwords had a colon (Github/peterloron)
src/com/gitblit/LuceneExecutor.java
@@ -1205,7 +1205,13 @@
            return "<pre class=\"text\">" + StringUtils.escapeForHtml(fragment, true) + "</pre>";
        }
        
        int contentPos = 0;
        // make sure we have unique fragments
        Set<String> uniqueFragments = new LinkedHashSet<String>();
        for (String fragment : fragments) {
            uniqueFragments.add(fragment);
        }
        fragments = uniqueFragments.toArray(new String[uniqueFragments.size()]);
        StringBuilder sb = new StringBuilder();
        for (int i = 0, len = fragments.length; i < len; i++) {
            String fragment = fragments[i];
@@ -1215,7 +1221,7 @@
            String raw = fragment.replace(termTag, "").replace(termTagEnd, "");
            // determine position of the raw fragment in the content
            int pos = content.indexOf(raw, contentPos);
            int pos = content.indexOf(raw);
                
            // restore complete first line of fragment
            int c = pos;
@@ -1243,8 +1249,6 @@
                }
                tag = MessageFormat.format("<pre class=\"prettyprint linenums:{0,number,0}{1}\">", line, lang);
                                
                // update offset into content
                contentPos = pos + raw.length() + 1;
            }
            
            sb.append(tag);