-
Notifications
You must be signed in to change notification settings - Fork 37
Modernize plugin for Gradle 9.x and AGP 8.x compatibility #42
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,14 @@ | ||
| package com.android.gradle.replicator | ||
|
|
||
| import com.android.gradle.replicator.model.internal.filedata.* | ||
| import com.android.utils.XmlUtils | ||
| import org.xml.sax.Attributes | ||
| import org.xml.sax.InputSource | ||
| import org.xml.sax.Locator | ||
| import org.xml.sax.SAXParseException | ||
| import org.xml.sax.helpers.DefaultHandler | ||
| import java.io.File | ||
| import java.io.StringReader | ||
| import javax.xml.XMLConstants | ||
| import javax.xml.parsers.SAXParserFactory | ||
|
|
||
| // Method to create the correct data class. Need to make this so it scans the files appropriately | ||
|
|
@@ -114,10 +114,19 @@ fun parseValuesFile(valuesFile: File): ValuesMap { | |
| } | ||
| } | ||
|
|
||
| val factory = SAXParserFactory.newInstance() | ||
| // Parse the input | ||
| XmlUtils.configureSaxFactory(factory, false, false) | ||
| val saxParser = XmlUtils.createSaxParser(factory) | ||
| val factory = SAXParserFactory.newInstance().apply { | ||
| // Configure safely without external entity processing | ||
| isNamespaceAware = false | ||
| isValidating = false | ||
| try { | ||
| setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true) | ||
| setFeature("http://xml.org/sax/features/external-general-entities", false) | ||
| setFeature("http://xml.org/sax/features/external-parameter-entities", false) | ||
| } catch (e: Exception) { | ||
| // Ignore if features not supported | ||
| } | ||
|
Comment on lines
+125
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Catching a generic } catch (e: Exception) {
// Ignore if features not supported, but log a warning.
println("Warning: Failed to set security features on SAX parser: ${e.message}")
} |
||
| } | ||
| val saxParser = factory.newSAXParser() | ||
| try { | ||
| saxParser.parse(InputSource(StringReader(valuesFile.readText())), handler) | ||
| } catch (e: SAXParseException) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic for reconstructing the project path is a bit complex and contains some redundant code due to the nested
if-elsestructure and repeatedelseblocks. It can be refactored to be more linear and easier to read, which will improve maintainability.