[SERVER-20736] Escaping double quote in string within braces triggers an end of input Created: 02/Oct/15  Updated: 06/Dec/22  Resolved: 03/Dec/21

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.0.6
Fix Version/s: None

Type: Bug Priority: Trivial - P5
Reporter: Maxime Darçot Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Won't Fix Votes: 0
Labels: move-sa, move-stm, platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-40911 JS Error Closed
Assigned Teams:
Server Tooling & Methods
Operating System: ALL
Steps To Reproduce:
  • Open MongoDB shell
  • Open a curly bracket : "{", and hit enter
  • "..." appears for you to continue your command
  • Create the following variable quote: var quote="\"";
  • Hit enter to continue your command
    --> SyntaxError

But if you change var quote="\""; by var quote=" \""; it will work and let you finish your command and close your bracket.

Participants:

 Description   

If you want to use double quotes in a string, you just have to escape it: \"
But if you insert this escaped character right after the beginning of a string when you are within curly brackets block, it will trigger an error:
"SyntaxError: Unexpected end of input"



 Comments   
Comment by Brooke Miller [ 03/Dec/21 ]

We've deprecated the mongo shell in favor of the new[ mongosh|https://docs.mongodb.com/mongodb-shell/]. Unfortunately, we aren't able to pursue improvements to the deprecated shell except in extreme cases, such as critical security fixes. Please start making use of[ mongosh|https://docs.mongodb.com/mongodb-shell/] and let us know if it works for you in this case.

Comment by Shivakumar Kamtala [ 17/Sep/19 ]

we have this issue and looking for an alternate fix, thank you.

Comment by Kelsey Schubert [ 03/May/19 ]

After completing this ticket, we should revisit the examples in SERVER-40911.

Comment by Stennie Steneker (Inactive) [ 02/Oct/15 ]

Hi Maxime,

Thanks for the bug report and steps to reproduce.

Regards,
Stephen

Generated at Thu Feb 08 03:55:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.