Skip to content

Commit

Permalink
Fix author list parser (JabRef#4169)
Browse files Browse the repository at this point in the history
  • Loading branch information
1160300208 committed Aug 7, 2018
1 parent 89f855d commit 9fafd06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Window state is saved on close and restored on start.
- Files without a defined external file type are now directly opened with the default aplication of the operating system
- We streamlined the process to rename and move files by removing the confirmation dialogs.
- We removed the redundant new lines of markings and wrapped the summary in the File annotation tab. [#3823](https://github.com/JabRef/jabref/issues/3823)



Expand Down Expand Up @@ -62,7 +63,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the default entry preview style still contained the field `review`. The field `review` in the style is now replaced with comment to be consistent with the entry editor [#4098](https://github.com/JabRef/jabref/issues/4098)
- We fixed an issue where users were vulnerable to XXE attacks during parsing [#4229](https://github.com/JabRef/jabref/issues/4229)
- We fixed an issue where files added via the "Attach file" contextmenu of an entry were not made relative. [#4201](https://github.com/JabRef/jabref/issues/4201)

- We fixed an issue where author list parser can't generate bibtex for Chinese author. [#4169](https://github.com/JabRef/jabref/issues/4169)



Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/jabref/model/entry/AuthorListParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ private Optional<Author> getAuthor() {
false);
String jrPart = jrPartStart < 0 ? null : concatTokens(tokens, jrPartStart, jrPartEnd, OFFSET_TOKEN, false);

if ((firstPart != null) && (lastPart != null) && lastPart.equals(lastPart.toUpperCase(Locale.ROOT)) && (lastPart.length() < 5)) {
if ((firstPart != null) && (lastPart != null) && lastPart.equals(lastPart.toUpperCase(Locale.ROOT)) && (lastPart.length() < 5)
&& (Character.UnicodeScript.of(lastPart.charAt(0)) != Character.UnicodeScript.HAN)) {
// The last part is a small string in complete upper case, so interpret it as initial of the first name
// This is the case for example in "Smith SH" which we think of as lastname=Smith and firstname=SH
// The length < 5 constraint should allow for "Smith S.H." as input
Expand Down Expand Up @@ -378,7 +379,7 @@ private int getToken() {
}
if (!firstLetterIsFound && (currentBackslash < 0) && Character.isLetter(c)) {
if (bracesLevel == 0) {
tokenCase = Character.isUpperCase(c);
tokenCase = Character.isUpperCase(c) || (Character.UnicodeScript.of(c) == Character.UnicodeScript.HAN);
} else {
// If this is a particle in braces, always treat it as if it starts with
// an upper case letter. Otherwise a name such as "{van den Bergen}, Hans"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class AuthorListParameterTest {
public static Collection<Object[]> data() {

return Arrays.asList(new Object[][] {
{"王, 军", authorList(new Author("军", "军.", null, "王", null))},
{ "Doe, John", authorList(new Author("John", "J.", null, "Doe", null)) },
{ "von Berlichingen zu Hornberg, Johann Gottfried",
authorList(new Author("Johann Gottfried", "J. G.", "von", "Berlichingen zu Hornberg", null)) },
Expand Down

0 comments on commit 9fafd06

Please sign in to comment.