-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an integrity check to ensure that a url has a correct protocol, i…
…mplements #358
- Loading branch information
1 parent
17a06b3
commit 956ddfa
Showing
19 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ public class IntegrityCheck { | |
public static final Checker TITLE_CHECKER = new TitleChecker(); | ||
public static final Checker BRACKET_CHECKER = new BracketChecker(); | ||
public static final Checker PAGES_CHECKER = new PagesChecker(); | ||
public static final Checker URL_CHECKER = new UrlChecker(); | ||
|
||
public List<IntegrityMessage> checkBibtexDatabase(BibDatabase base) { | ||
List<IntegrityMessage> result = new ArrayList<>(); | ||
|
@@ -69,6 +70,11 @@ public List<IntegrityMessage> checkBibtexEntry(BibEntry entry) { | |
PAGES_CHECKER.check(data.toString(), "pages", entry, result); | ||
} | ||
|
||
data = entry.getField("url"); | ||
if (data != null) { | ||
URL_CHECKER.check(data.toString(), "url", entry, result); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
@@ -77,6 +83,16 @@ public interface Checker { | |
void check(String value, String fieldName, BibEntry entry, List<IntegrityMessage> collector); | ||
} | ||
|
||
private static class UrlChecker implements Checker { | ||
|
||
@Override | ||
public void check(String value, String fieldName, BibEntry entry, List<IntegrityMessage> collector) { | ||
if(!value.contains("://")) { | ||
collector.add(new IntegrityMessage(Localization.lang("should contain a protocol") + ": http[s]://, file:// or ftp://", entry, fieldName)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
simonharrer
Author
Contributor
|
||
} | ||
} | ||
} | ||
|
||
private static class AuthorNameChecker implements Checker { | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@simonharrer: the
or
is not translated :-)