JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler

NEW : We have got a new blog where we post some interesting SWF internals info.

List of issuesList of issues

#2183 Variable usages named "newline" get compiled into "\n"
Author: user kjarosh
Date created:
Type: bug
Visibility: Everybody
Assigned to:
State: closed Help

> What steps will reproduce the problem? Create a new tag "DoAction" and click "Edit ActionScript". Paste the following code: var newline = "test"; trace(newline); Click "Save", and observe the resulting P-code and decompiled code. > What is the expected output? What do you see instead? I would expect to see: var newline = "test"; trace(newline); but I see instead: var newline = "test"; trace("\n"); Seems like the variable named "newline" got translated into a literal string with a newline. > What version of the product are you using? Is it "nightly build"? Which operating system do you have? Version 20.1.0 through flatpak, Fedora 38. > Please provide any additional information below. If the problem is related to a SWF file, attach it here, otherwise we can't help you.
admin
In ActionScript 1/2, newline is reserved constant with value of "\n". https://www.oreilly.com/library/view/actionscript-the-definitive/1565928520/re170.html You cannot have your own variable with that name. If you print it out, it always have value of "\n" no matter what you assigned to it - see attachment. FFDec decompiles "newline" constant to its original form "\n" because it cannot be distinguished from the bytecode whether newline constant was used or raw "\n". This is not a bug.
State: new→opened
Type: bug→question
user
Thank you for taking your time and looking into this! I apologize, I was not aware of the "newline" constant (I searched for it I promise). However I do still think there's a bug in this case, but I have provided a wrong example due to my ignorance. Please let me rephrase the problem. I have stumbled upon a DoAction tag in an SWF which upon decompiling and compiling by JPEXS produces broken code. I spent some time (it had over 2k lines of code) and debugged why this is the case and found that there's a function which has a parameter named "newLine", and its usages were replaced by JPEXS to "\n". P-code of the function definition: DefineFunction2 "functionName", 1, 3, false, true, true, false, true, false, true, false, false, 2, "newLine" P-code of the variable usage: Push register2 When decompiled, the function looks like this: function functionName(newLine) { trace(newLine); } When compiled again, the instruction "Push register2" is being replaced by Push "\n" And when decompiled again it looks like this: function functionName(newLine) { trace("\n"); } I'm thinking it's a bug because decompiling the code and compiling it again breaks it, but the user does not expect it to do so. I am not sure here whether the newline constant is case-sensistive or not (the parameter was named newLine, not newline), but it seems like a parameter named "newline" could also exist in P-code and its usage also could be translated to "\n". It seems that ensuring code semantics is more important than preserving variable name in this case.
admin
Please try nightly 2769, it should be fixed. Identifiers are case sensitive since SWF version 7.
State: opened→upgraded
Type: question→bug
user
It does work, thank you!
admin
You're welcome.
State: upgraded→closed