Skip to content
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

Escaping characters are double-escaped after editing in the assembly pane #723

Open
lanvent opened this issue Sep 21, 2023 · 2 comments
Open

Comments

@lanvent
Copy link

lanvent commented Sep 21, 2023

Hi, I have been using your tool for manipulating Java bytecode and it has been extremely useful. However, I recently stumbled upon a bug in version 3.x that has been quite troubling.

When editing Java bytecode in the assembly pane (not the decompile pane), the escape characters get double-escaped after making a change to the code. This issue is specific to version 3.x, as the same changes do not result in this problem in version 2.21.

Steps to Reproduce:

  1. Given the source code:
package org.test;

public class recaf {
    public recaf() {
    }

    public static void main(String[] args) {
        String str = "\"test\"";
        System.out.println(str);
        System.out.println(str);
    }
}
  1. Generate the class file for the above code. Open the class file in the assembly pane.
  2. Delete one of the System.out.println(str); related lines.
  3. After the deletion, the source code appears as:
package org.test;

public class recaf {
    public static void main(String[] args) {
        String str = "\\\"test\\\"";
        System.out.println(str);
    }
}

As you can see, the String str = "\"test\""; has been transformed into String str = "\\\"test\\\"";, which should not happen.

In version 2.21, this issue does not occur, and the string remains as String str = "\"test\"";.

Thank you for your time and efforts on this great tool.

@Col-E
Copy link
Owner

Col-E commented Sep 21, 2023

We were handling escaping in a number of different places and it led to a bit of a mess of "who's doing what where?"

The parser back-end JASM has been rewritten and is being re-incorporated here: #722

It handles all of the escaping locally so its no longer as messy as it was before, and we've confirmed the issue is solved in the rewrite.

@Col-E Col-E transferred this issue from Col-E/recaf-3x-issues Sep 21, 2023
@lanvent
Copy link
Author

lanvent commented Sep 21, 2023

Thank you for your quick response to the issue. It's great to hear that the problem has been identified and is already being addressed. Looking forward to either seeing this fix incorporated into an upcoming 3.x version or experiencing the enhanced assembly functionalities in the forthcoming 4.x. The assembly functionality is crucial for many users like myself, and it's exciting to see it getting the attention it deserves for further refinement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants