diff --git a/brut.apktool/apktool-cli/build.gradle b/brut.apktool/apktool-cli/build.gradle index c8ea405d536..5d8a7dd3f12 100644 --- a/brut.apktool/apktool-cli/build.gradle +++ b/brut.apktool/apktool-cli/build.gradle @@ -89,7 +89,6 @@ tasks.register('proguard', ProGuardTask) { dontwarn 'javax.xml.xpath.**' dontnote '**' // between Java 1.8 and 1.9, the signature of `flip()` changed, which trips up proguard. - dontwarn 'org.yaml.snakeyaml.scanner.ScannerImpl' def outPath = jar.getDestinationDirectory().getAsFile().get().toString() def extension = jar.archiveExtension.get().toString() diff --git a/brut.apktool/apktool-lib/build.gradle b/brut.apktool/apktool-lib/build.gradle index 080ffb7771f..dcfa8ac5dec 100644 --- a/brut.apktool/apktool-lib/build.gradle +++ b/brut.apktool/apktool-lib/build.gradle @@ -39,7 +39,6 @@ dependencies { implementation depends.baksmali implementation depends.smali - implementation depends.snakeyaml implementation depends.xmlpull implementation depends.guava implementation depends.commons_lang diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ApkInfo.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ApkInfo.java index 0a73b320f75..0d674ab05bf 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ApkInfo.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ApkInfo.java @@ -21,10 +21,6 @@ import brut.androlib.res.data.ResConfigFlags; import brut.directory.DirectoryException; import brut.directory.FileDirectory; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.LoaderOptions; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.introspector.PropertyUtils; import java.io.*; import java.util.ArrayList; @@ -54,26 +50,6 @@ public ApkInfo() { this.version = ApktoolProperties.getVersion(); } - private static Yaml getYaml() { - DumperOptions dumpOptions = new DumperOptions(); - dumpOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - - EscapedStringRepresenter representer = new EscapedStringRepresenter(); - PropertyUtils propertyUtils = representer.getPropertyUtils(); - propertyUtils.setSkipMissingProperties(true); - - LoaderOptions loaderOptions = new LoaderOptions(); - loaderOptions.setCodePointLimit(10 * 1024 * 1024); // 10mb - - return new Yaml(new ClassSafeConstructor(), representer, dumpOptions, loaderOptions); - } - - public void save(Writer output) { - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - getYaml().dump(this, output); - } - public String checkTargetSdkVersionBounds() { int target = mapSdkShorthandToVersion(getTargetSdkVersion()); @@ -157,16 +133,6 @@ private int mapSdkShorthandToVersion(String sdkVersion) { } } -// public void save(File file) throws IOException { -// try( -// FileOutputStream fos = new FileOutputStream(file); -// OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fos, StandardCharsets.UTF_8); -// Writer writer = new BufferedWriter(outputStreamWriter) -// ) { -// save(writer); -// } -// } - public void save(File file) throws AndrolibException { try ( YamlWriter writer = new YamlWriter(new FileOutputStream(file)); @@ -187,17 +153,6 @@ public static ApkInfo load(InputStream is) throws AndrolibException { return apkInfo; } -// public static ApkInfo load(File appDir) -// throws AndrolibException { -// try( -// InputStream in = new FileDirectory(appDir).getFileInput("apktool.yml") -// ) { -// return ApkInfo.load(in); -// } catch (DirectoryException | IOException ex) { -// throw new AndrolibException(ex); -// } -// } - public static ApkInfo load(File appDir) throws AndrolibException { try( diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ClassSafeConstructor.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ClassSafeConstructor.java deleted file mode 100644 index d1849ec05bb..00000000000 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ClassSafeConstructor.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2010 Ryszard Wiśniewski - * Copyright (C) 2010 Connor Tumbleson - * - * Licensed 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 brut.androlib.apk; - -import org.yaml.snakeyaml.constructor.AbstractConstruct; -import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.error.YAMLException; -import org.yaml.snakeyaml.LoaderOptions; -import org.yaml.snakeyaml.nodes.Node; -import org.yaml.snakeyaml.nodes.ScalarNode; -import org.yaml.snakeyaml.nodes.Tag; -import java.util.ArrayList; -import java.util.List; - -public class ClassSafeConstructor extends Constructor { - protected final List> allowableClasses = new ArrayList<>(); - - public ClassSafeConstructor() { - super(new LoaderOptions()); - this.yamlConstructors.put(Tag.STR, new ConstructStringEx()); - - this.allowableClasses.add(ApkInfo.class); - this.allowableClasses.add(PackageInfo.class); - this.allowableClasses.add(UsesFramework.class); - this.allowableClasses.add(VersionInfo.class); - } - - protected Object newInstance(Node node) { - if (this.yamlConstructors.containsKey(node.getTag()) || this.allowableClasses.contains(node.getType())) { - return super.newInstance(node); - } - throw new YAMLException("Invalid Class attempting to be constructed: " + node.getTag()); - } - - protected Object finalizeConstruction(Node node, Object data) { - if (this.yamlConstructors.containsKey(node.getTag()) || this.allowableClasses.contains(node.getType())) { - return super.finalizeConstruction(node, data); - } - - return this.newInstance(node); - } - - private class ConstructStringEx extends AbstractConstruct { - public Object construct(Node node) { - String val = constructScalar((ScalarNode) node); - return YamlStringEscapeUtils.unescapeString(val); - } - } -} diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/EscapedStringRepresenter.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/EscapedStringRepresenter.java deleted file mode 100644 index c2b13f9e00b..00000000000 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/EscapedStringRepresenter.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2010 Ryszard Wiśniewski - * Copyright (C) 2010 Connor Tumbleson - * - * Licensed 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 brut.androlib.apk; - -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.nodes.Node; -import org.yaml.snakeyaml.representer.Representer; - -public class EscapedStringRepresenter extends Representer { - public EscapedStringRepresenter() { - super(new DumperOptions()); - RepresentStringEx representStringEx = new RepresentStringEx(); - multiRepresenters.put(String.class, representStringEx); - representers.put(String.class, representStringEx); - } - - private class RepresentStringEx extends RepresentString { - - @Override - public Node representData(Object data) { - return super.representData(YamlStringEscapeUtils.escapeString(data.toString())); - } - } -} diff --git a/build.gradle b/build.gradle index 4b7f2733e16..a64f40fe78d 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,6 @@ buildscript { guava : 'com.google.guava:guava:32.0.1-jre', junit : 'junit:junit:4.13.2', proguard_gradle: 'com.guardsquare:proguard-gradle:7.3.2', - snakeyaml : 'org.yaml:snakeyaml:1.32:android', smali : 'com.android.tools.smali:smali:3.0.3', xmlpull : 'xpp3:xpp3:1.1.4c', xmlunit : 'xmlunit:xmlunit:1.6',