Skip to content

Commit

Permalink
Fixed #1643: Searching with double quotes in a specific field ignores…
Browse files Browse the repository at this point in the history
… the last character
  • Loading branch information
simonharrer committed Aug 2, 2016
1 parent e8a083c commit 2c9c7dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed [#1639](https://github.com/JabRef/jabref/issues/1639): Google Scholar fetching works again.
- Date fields in the BibLatex standard are now always formatted in the correct way, independent of the preferences
- Fixed [#1554]: Import dialog is no longer hidden behind main window
- Fixed [#1643]: Searching with double quotes in a specific field ignores the last character

### Removed
- It is not longer possible to choose to convert HTML sub- and superscripts to equations
Expand Down Expand Up @@ -490,4 +491,4 @@ The changelog of 2.11 and versions before is maintained as [text file](https://g
[3.1]: https://github.com/JabRef/jabref/compare/v3.0...v3.1
[3.0]: https://github.com/JabRef/jabref/compare/v2.11.1...v3.0
[dev_2.11]: https://github.com/JabRef/jabref/compare/v2.11.1...dev_2.11
[2.11.1]: https://github.com/JabRef/jabref/compare/v2.11...v2.11.1
[2.11.1]: https://github.com/JabRef/jabref/compare/v2.11...v2.11.1
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public Boolean visitComparison(SearchParser.ComparisonContext ctx) {
// remove possible enclosing " symbols
String right = ctx.right.getText();
if(right.startsWith("\"") && right.endsWith("\"")) {
right = right.substring(1, right.length() - 2);
right = right.substring(1, right.length() - 1);
}

return comparison(ctx.left.getText(), ComparisonOperator.build(ctx.operator.getText()), right);
Expand Down
19 changes: 18 additions & 1 deletion src/test/java/net/sf/jabref/logic/search/SearchQueryTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.sf.jabref.logic.search;

import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;

import org.junit.Test;

Expand Down Expand Up @@ -38,4 +39,20 @@ public void testGrammarSearch() {
assertTrue(searchQuery.isMatch(entry));
}

}
@Test
public void testGrammarSearchFullEntryLastCharMissing() {
BibEntry entry = new BibEntry();
entry.setField(FieldName.TITLE, "systematic revie");
SearchQuery searchQuery = new SearchQuery("title=\"systematic review\"", false, false);
assertFalse(searchQuery.isMatch(entry));
}

@Test
public void testGrammarSearchFullEntry() {
BibEntry entry = new BibEntry();
entry.setField(FieldName.TITLE, "systematic review");
SearchQuery searchQuery = new SearchQuery("title=\"systematic review\"", false, false);
assertTrue(searchQuery.isMatch(entry));
}

}

0 comments on commit 2c9c7dd

Please sign in to comment.