Skip to content

Commit

Permalink
Merge pull request #1823 from JabRef/fix1804
Browse files Browse the repository at this point in the history
Fixed #1804: URL field is not removed by integrity check
  • Loading branch information
stefan-kolb authored Aug 23, 2016
2 parents 3ba0dc4 + daf1aba commit 21069a4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed [#1499](https://github.com/JabRef/jabref/issues/1499): {} braces are now treated correctly in in author/editor
- Fixed [#1531](https://github.com/JabRef/jabref/issues/1531): `\relax` can be used for abbreviation of author names
- Fixed [#1771](https://github.com/JabRef/jabref/issues/1771): Show all supported import types as default
- Fixed [#1804](https://github.com/JabRef/jabref/issues/1804): Integrity check no longer removes URL field by mistake



### Removed
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/net/sf/jabref/logic/integrity/IntegrityCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,19 @@ public List<IntegrityMessage> check(BibEntry entry) {
List<IntegrityMessage> results = new ArrayList<>();

Map<String, String> fields = entry.getFieldMap();
// the url field should not be checked for hashes, as they are legal in this field
fields.remove(FieldName.URL);


for (Map.Entry<String, String> field : fields.entrySet()) {
Matcher hashMatcher = UNESCAPED_HASH.matcher(field.getValue());
int hashCount = 0;
while (hashMatcher.find()) {
hashCount++;
}
if ((hashCount & 1) == 1) { // Check if odd
results.add(
new IntegrityMessage(Localization.lang("odd number of unescaped '#'"), entry,
field.getKey()));
if (!InternalBibtexFields.getFieldExtras(field.getKey()).contains(FieldProperties.VERBATIM)) {
Matcher hashMatcher = UNESCAPED_HASH.matcher(field.getValue());
int hashCount = 0;
while (hashMatcher.find()) {
hashCount++;
}
if ((hashCount & 1) == 1) { // Check if odd
results.add(new IntegrityMessage(Localization.lang("odd number of unescaped '#'"), entry,
field.getKey()));
}
}
}
return results;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/sf/jabref/model/entry/FieldProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum FieldProperties {
BOOK_NAME,
SINGLE_ENTRY_LINK,
MULTIPLE_ENTRY_LINK,
PUBLICATION_STATE;
PUBLICATION_STATE,
VERBATIM;

public static final Set<FieldProperties> ALL_OPTS = EnumSet.allOf(FieldProperties.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public class InternalBibtexFields {
"ctlalt_stretch_factor", FieldName.VOLUMES);
public static final List<String> IEEETRANBSTCTL_YES_NO_FIELDS = Arrays.asList("ctluse_article_number",
"ctluse_paper", "ctluse_url", "ctluse_forced_etal", "ctluse_alt_spacing", "ctldash_repeated_names");
public static final List<String> BIBLATEX_DATE_FIELDS = Arrays.asList(FieldName.DATE, "eventdate", "origdate", FieldName.URLDATE);
public static final List<String> BIBLATEX_DATE_FIELDS = Arrays.asList(FieldName.DATE, "eventdate", "origdate",
FieldName.URLDATE);
public static final List<String> BIBLATEX_PERSON_NAME_FIELDS = Arrays.asList(FieldName.AUTHOR, FieldName.EDITOR,
"editora", "editorb", "editorc", FieldName.TRANSLATOR, "annotator", "commentator", "introduction", "foreword",
"afterword", FieldName.BOOKAUTHOR, "holder", "shortauthor", "shorteditor", "sortname", "nameaddon");
Expand Down Expand Up @@ -156,14 +157,14 @@ private InternalBibtexFields(boolean serializeSpecialFields, String timeStampFie
add(new BibtexSingleField(FieldName.ABSTRACT, false, BibtexSingleField.LARGE_W, 400));

dummy = new BibtexSingleField(FieldName.URL, false, BibtexSingleField.SMALL_W);
dummy.setExtras(EnumSet.of(FieldProperties.EXTERNAL));
dummy.setExtras(EnumSet.of(FieldProperties.EXTERNAL, FieldProperties.VERBATIM));
add(dummy);

add(new BibtexSingleField("comment", false, BibtexSingleField.MEDIUM_W));
add(new BibtexSingleField(FieldName.KEYWORDS, false, BibtexSingleField.SMALL_W));

dummy = new BibtexSingleField(FieldName.FILE, false);
dummy.setExtras(EnumSet.of(FieldProperties.FILE_EDITOR));
dummy.setExtras(EnumSet.of(FieldProperties.FILE_EDITOR, FieldProperties.VERBATIM));
add(dummy);

add(new BibtexSingleField("search", false, 75));
Expand Down

0 comments on commit 21069a4

Please sign in to comment.