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

Detection of new line before this in replace_this_non_prop in probably buggy #410

Open
benoit74 opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@benoit74
Copy link
Collaborator

In JS rewriting, we have a replace_this_non_prop rule to for instance transform:

  • a = this; into a = _____WB$wombat$check$this$function_____(this)
  • return this.location into return _____WB$wombat$check$this$function_____(this).location

and so on.

There is a space case to not replace followings:

  • a = this.color (custom global color, do not care)
  • aaa.this.window=red (this is just a random property)

There is also a space case to add a semi-colon ; if previous characters is a new line.

However it works only on aaa\n this.window=red (2 spaces before this) which is transformed into aaa\n ;_____WB$wombat$check$this$function_____(this).window=red.

But not on aaa\nthis.window=red (0 space before this) or aaa\n this.window=red (1 space before this) or aaa\n this.window=red (4 space before this).

I think this is a bug, and that this bug is also present upstream in wabac.js. I'm however not exactly sure why one needs to add a semi-colon after the carriage return, so it is hard to know how to fix this properly ATM

@benoit74 benoit74 added the bug Something isn't working label Oct 17, 2024
@benoit74
Copy link
Collaborator Author

The regex is also buggy, it does rewrite aaa. this.window=red and aaa$ this.window=red while it should be kept unmodified for same reason, it accounts only for one or two spaces while javascript has theoritically no limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant