-
Notifications
You must be signed in to change notification settings - Fork 53
RAT-539: Update xml writer #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Claudenw
wants to merge
19
commits into
master
Choose a base branch
from
update-XMLWriter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
913aa80
moved Char handling to XMLChar, switched XmlWriter to write to appender
Claudenw b92229a
added checkstyle supressions to and made XMLChar final
Claudenw 6849cc1
Fixed issue with not closing stream before tryiong to read
Claudenw 2d19d32
updated test
Claudenw ad1de6b
added append() method to IXmlWriter
Claudenw a1cb178
fixed XXE issue
Claudenw 28751f5
fixed checkstyle error
Claudenw 082ef2f
added checkstyle supression for XMLChar.java
Claudenw f29aea1
fixed spotbugs issues
Claudenw 074f977
attempt at sonar exclusion
Claudenw 2219923
fixed XXE issue and added testing
Claudenw 62164f5
resolved XsdGenerator issue
Claudenw 45e3273
attempt to fix windows line end problem
Claudenw 1f83345
fixed sonar issues
Claudenw 13106f1
added pom comment
Claudenw 0d1ae8f
fixed formatting issue
Claudenw 0efc958
LHF: fix javadoc
ottlinger b0b53c3
Add reference to RAT-539 in pom comment
ottlinger 088db7d
Add reference to RAT-539 in checkstylecomment
ottlinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
1,068 changes: 1,068 additions & 0 deletions
1,068
apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XMLChar.java
Large diffs are not rendered by default.
Oops, something went wrong.
563 changes: 88 additions & 475 deletions
563
apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XmlWriter.java
Large diffs are not rendered by default.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
apache-rat-core/src/main/java/org/apache/rat/utils/StandardXmlFactory.java
This file contains hidden or 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,67 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.rat.utils; | ||
|
|
||
| import java.io.InputStream; | ||
|
|
||
| import javax.xml.XMLConstants; | ||
| import javax.xml.transform.OutputKeys; | ||
| import javax.xml.transform.Transformer; | ||
| import javax.xml.transform.TransformerConfigurationException; | ||
| import javax.xml.transform.TransformerFactory; | ||
| import javax.xml.transform.stream.StreamSource; | ||
|
|
||
| /** | ||
| * Factory to create standard XML objects. The intention of this class is to resolve in a consistent manner the | ||
| * XXE errors and similar XML IO errors. | ||
| */ | ||
| public final class StandardXmlFactory { | ||
|
|
||
| private StandardXmlFactory() { | ||
| // do not instantiate. | ||
| } | ||
| /** | ||
| * Create a transformer with no stylesheet. | ||
| * @return the transformer. | ||
| * @throws TransformerConfigurationException on error. | ||
| */ | ||
| public static Transformer create() throws TransformerConfigurationException { | ||
| return create(null); | ||
| } | ||
|
|
||
| /** | ||
| * Create a transformer with the specified stylesheet. | ||
| * @param styleIn the stylesheet to use. | ||
| * @return the transformer. | ||
| * @throws TransformerConfigurationException on error. | ||
| */ | ||
| public static Transformer create(final InputStream styleIn) throws TransformerConfigurationException { | ||
| TransformerFactory factory = TransformerFactory.newInstance(); | ||
| factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); | ||
| factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); | ||
| factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); | ||
| Transformer transformer = styleIn == null ? factory.newTransformer() : factory.newTransformer(new StreamSource(styleIn)); | ||
| transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); | ||
| transformer.setOutputProperty(OutputKeys.METHOD, "xml"); | ||
| transformer.setOutputProperty(OutputKeys.INDENT, "yes"); | ||
| transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); | ||
| transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); | ||
| return transformer; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.