-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify rule S2755: Simplify how to fix it section (#4215)
- Loading branch information
1 parent
6baf583
commit e5ae27a
Showing
6 changed files
with
78 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
== How to fix it in SAX | ||
|
||
=== Code examples | ||
|
||
include::../../common/fix/code-rationale.adoc[] | ||
|
||
==== Noncompliant code example | ||
|
||
[source,java,diff-id=31,diff-type=noncompliant] | ||
---- | ||
import org.xml.sax.XMLReader; | ||
import org.xml.sax.helpers.XMLReaderFactory; | ||
public void decode() { | ||
XMLReader reader = XMLReaderFactory.createXMLReader(); // Noncompliant | ||
} | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
Set `disallow-doctype-decl` to `true`. | ||
|
||
[source,java,diff-id=31,diff-type=compliant] | ||
---- | ||
import org.xml.sax.XMLReader; | ||
import org.xml.sax.helpers.XMLReaderFactory; | ||
public void decode() { | ||
XMLReader reader = XMLReaderFactory.createXMLReader(); | ||
reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); | ||
} | ||
---- | ||
|
||
=== How does this work? | ||
|
||
include::../../common/fix/xxe.adoc[] |
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