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

Unterminated string literal #4893

Closed
Btaralte opened this issue Sep 11, 2023 · 6 comments · Fixed by #5318
Closed

Unterminated string literal #4893

Btaralte opened this issue Sep 11, 2023 · 6 comments · Fixed by #5318
Labels
bug Something isn't working

Comments

@Btaralte
Copy link

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

 const SMS = {
     TOKEN: "[TOKEN]",
     TEMPLATES: {
         FORGOT_PASSWORD: "Your forgot password link!\
		\nLINK\
		\n \
		\nRegards, \n ",
     }
 }; 

Due to this code bun throws this errror.


error: Unterminated string literal

         FORGOT_PASSWORD: "Your forgot password link!\

nodejs is able to run this.

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@Btaralte Btaralte added the bug Something isn't working label Sep 11, 2023
@Jarred-Sumner
Copy link
Collaborator

It looks like not all the text was copy pasted correctly because the snippet provided in the github issue runs successfully on my machine

@Btaralte
Copy link
Author

Hi I figured out providing the whole code snippet will not reproduce the problem as when I copy paste into a new file,bun run succesfully.But when i created the copy of the file itself, I was able to recreate the problem.Also when i commented this snippet from the original file, bun run succesfully.

@leventkaragol
Copy link

Could there be a Unicode character that does not appear in the file? I also ran it without any problems.

@Btaralte
Copy link
Author

Hi, i had run a python script to check for unicode characters,there are no characters which fall outside the ASCII for the file which bun wasn't able to run. This is the hexadecimal representation for the file which cause the problem.

00000000: 200d 0a63 6f6e 7374 2053 4d53 203d 207b ..const SMS = { 00000010: 0d0a 2020 2020 544f 4b45 4e3a 2022 5b54 .. TOKEN: "[T 00000020: 4f4b 454e 5d22 2c0d 0a20 2020 2054 454d OKEN]",.. TEM 00000030: 504c 4154 4553 3a20 7b0d 0a20 2020 2020 PLATES: {.. 00000040: 2020 2046 4f52 474f 545f 5041 5353 574f FORGOT_PASSWO 00000050: 5244 3a20 2259 6f75 7220 666f 7267 6f74 RD: "Your forgot 00000060: 2070 6173 7377 6f72 6420 6c69 6e6b 215c password link!\ 00000070: 0d0a 0909 5c6e 4c49 4e4b 5c0d 0a09 095c ....\nLINK\....\ 00000080: 6e20 5c0d 0a09 095c 6e52 6567 6172 6473 n \....\nRegards 00000090: 2c20 5c6e 2022 2c0d 0a20 2020 207d 0d0a , \n ",.. }.. 000000a0: 7d3b 0d0a 20 };..

@Btaralte
Copy link
Author

Hi,I've included the file itself in a zip file
constant_copy.zip

@tikotzky
Copy link
Contributor

It seems like this error only happens when a line is terminated with a CR+LF if its terminated only with LF it works fine.

A simple reproduction is

node -e "fs.writeFileSync('bug.js',Buffer.from([0x22,0x61,0x5c,0x0d,0x0a,0x62,0x22]))" && bun bug.js

side question: is there a way to eval code like done above using bun?

tikotzky added a commit to tikotzky/bun that referenced this issue Sep 13, 2023
tikotzky added a commit to tikotzky/bun that referenced this issue Sep 13, 2023
Jarred-Sumner pushed a commit that referenced this issue Sep 14, 2023
* Fix bug with multiline string in CRLF terminated files (#4893)

* add test for #4893
paperdave pushed a commit to SuperAuguste/bun that referenced this issue Sep 18, 2023
…oven-sh#5318)

* Fix bug with multiline string in CRLF terminated files (oven-sh#4893)

* add test for oven-sh#4893
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

Successfully merging a pull request may close this issue.

4 participants