Skip to content

Commit

Permalink
Merge pull request #3908 from inception-project/refactoring/3907-Cons…
Browse files Browse the repository at this point in the history
…ider-editor-policy-only-if-format-does-not-offer-policy

#3907 - Consider editor policy only if format does not offer policy
  • Loading branch information
reckart committed Mar 29, 2023
2 parents d0e37b1 + 333550c commit 90e2cc2
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ protected ContentHandler applySanitizers(Optional<String> aEditor, SourceDocumen
// Apply safety net
var ch = new SanitizingContentHandler(aCh, safetyNetPolicy.getPolicy());

// Apply editor policy if it exists
var editorPolicy = getEditorPolicy(aEditor);
if (editorPolicy.isPresent()) {
ch = new SanitizingContentHandler(ch, editorPolicy.get());
}

// Apply format policy if it exists
var formatPolicy = formatRegistry.getFormatPolicy(doc);
if (formatPolicy.isPresent()) {
ch = new SanitizingContentHandler(ch, formatPolicy.get());
}

// Apply editor policy if it exists
var editorPolicy = getEditorPolicy(aEditor);
if (formatPolicy.isEmpty() && editorPolicy.isPresent()) {
ch = new SanitizingContentHandler(ch, editorPolicy.get());
}

// If neither a format nor an editor policy exists, apply the default policy
if (editorPolicy.isEmpty() && formatPolicy.isEmpty()) {
ch = new SanitizingContentHandler(ch, defaultPolicy.getPolicy());
Expand Down

0 comments on commit 90e2cc2

Please sign in to comment.