question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG - Develop] funcparser breaks when args contain an odd number of apostrophe or quote marks

See original GitHub issue

Describe the bug

When a string with an odd number of quote or apostrophe characters is put into a funcparser function, it fails to parse the function.

To Reproduce

Steps to reproduce the behavior:

  1. Put $crop(spider silk, 5) through the parser and verify it works (output: spide)
  2. Put $crop(spider's silk, 5) through the parser: one apostrophe, output: $crop(spider's silk, 5)
  3. Then put $crop(spider's' silk, 5) through the parser: two apostrophies, output: spide
  4. Lastly, put $crop('spider's' silk, 5) through the parser: three apostrophes, output: $crop('spider's' silk, 5)

Expected behavior

It should successfully parse the function when it’s being given a string that contains a single quote mark or apostrophe.

Develop-branch commit

7f4769bd9

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
Griatchcommented, Oct 29, 2022

Investigating this further, there seems no real way to support single-quoted strings within the funcparser structure while keeping quotes optional for the user (which we want to do, for simplicitly.

While it’s possible to count single quotes to try to guess if the quote is a quote or an apostrophe, this would still make inputs like this impossible:

"$crop(The wizard's spider's wicked web, 5)" 

No matter what you do, s spider will be considered a literal and the ' will be lost. It’s even clearer with another example:

"This is the $choice(spider's, devil's, mummy's, zombie's) curse!"

Here s, devil and s, zombie will be considered literal strings no matter how clever we design the '-parsing, because there is no way for the system to know the difference between this and

"This is $choice('Tiamat, queen of dragons', 'Dracula, lord of the night') we are talking about.")

It seems the only way around this is to not treat single quotes in funcparser funcs as literals at all - requiring double quotes.

If I remove special treatment of single quotes, this problem goes away completely. The drawback is that it doesn’t quite match Python syntax anymore (since ' and " wouldn’t nest like Python for example). The last $choice call above would become a choice between the strings 'Tiamat, queen of dragons, 'Dracula and lord of the night'. Using double-quotes becomes required.

But I think using apostrophes is more likely a thing than requiring to be able to escape with single quotes.

1reaction
ChrisLRcommented, Jun 6, 2022

I’m working on it btw, did some refactoring to make the fix easier, should have it working soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug with quotes in quotes and scripts (#1742) · Issues - GitLab
Hi, I have the following in my gitlab-ci.yml (I removed what I think ... and that breaks the use of quotes inside the...
Read more >
PowerShell stripping double quotes from command line ...
Powershell will auto-quote (enclose in < " >) a single argument string, if it contains spaces and the spaces don't mix with an...
Read more >
ASCII and Unicode quotation marks
In ASCII it is used to represent a punctuation mark (such as right single quotation mark, left single quotation mark, apostrophe punctuation, vertical...
Read more >
Apostrophes and double quotes don't show up until I type the ...
This happens with double quotes " , apostrophes ' and tilde ~ characters. What could possibly be causing this? This occurs in all...
Read more >
SQuirreL SQL Client / Bugs / #1480 Oracle alternate quoting ...
But if the literal string has an odd number of single quotation marks inside the literal string, e.g.. select q'{test' }' from dual;....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found