more hyperlink validation improvements
This commit is contained in:
parent
714b0a0fd4
commit
5d65102937
|
@ -1101,4 +1101,5 @@ public class I18nConstants {
|
|||
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_EMPTY_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_EMPTY_HREF";
|
||||
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF";
|
||||
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF";
|
||||
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF";
|
||||
}
|
||||
|
|
|
@ -1129,4 +1129,4 @@ NDJSON_EMPTY_LINE_WARNING = The NDJSON source contains an empty line. This may n
|
|||
TYPE_SPECIFIC_CHECKS_DT_XHTML_EMPTY_HREF = Hyperlink at ''{0}'' for ''{1}'' is empty
|
||||
TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF = Hyperlink scheme ''{3}'' in ''{0}'' at ''{1}'' for ''{2}'' has active content, which is a security risk and not allowed
|
||||
TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF = Hyperlink scheme ''{3}'' in ''{0}'' at ''{1}'' for ''{2}'' is not a widely supported protocol and should be checked
|
||||
|
||||
TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF = Hyperlink scheme ''{3}'' in ''{0}'' at ''{1}'' for ''{2}'' is not a valid hyperlinkable scheme
|
||||
|
|
|
@ -3329,7 +3329,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
} else if (href.contains(":")) {
|
||||
String scheme = href.substring(0, href.indexOf(":"));
|
||||
if (rule(errors, "2024-07-20", IssueType.INVALID, e.line(), e.col(), path, !isActiveScheme(scheme), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF, href, xpath, Utilities.stripEoln(node.allText()).trim(), scheme)) {
|
||||
hint(errors, NO_RULE_DATE, IssueType.INVALID, e.line(), e.col(), path, isKnownScheme(scheme), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF, href, xpath, node.allText().trim(), scheme);
|
||||
if (rule(errors, "2024-07-20", IssueType.INVALID, e.line(), e.col(), path, isLiteralScheme(scheme), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF, href, xpath, Utilities.stripEoln(node.allText()).trim(), scheme)) {
|
||||
hint(errors, NO_RULE_DATE, IssueType.INVALID, e.line(), e.col(), path, isKnownScheme(scheme), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF, href, xpath, node.allText().trim(), scheme);
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
// we can't validate at this point. Come back and revisit this some time in the future
|
||||
|
@ -3349,6 +3355,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
return Utilities.existsInList(scheme, "javascript", "vbscript");
|
||||
}
|
||||
|
||||
private boolean isLiteralScheme(String scheme) {
|
||||
return !Utilities.existsInList(scheme, "urn", "cid");
|
||||
}
|
||||
|
||||
private boolean isKnownScheme(String scheme) {
|
||||
return Utilities.existsInList(scheme, "http", "https", "tel", "mailto", "data");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue