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

Do not assume /\A["']/ strings are quoted #208

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Do not assume /\A["']/ strings are quoted #208

wants to merge 1 commit into from

Conversation

janikrabe
Copy link
Contributor

Do not assume that strings starting with a quote are quoted. For instance, the string "a b contains a space that needs to be escaped, so quoteIfNeeded should return "\"a b" rather than "a b.

Found while debugging GothenburgBitFactory/libshared#14.

Do not assume that strings starting with a quote are quoted. For
instance, the string `"a b` contains a space that needs to be escaped,
so quoteIfNeeded should return `"\"a b"` rather than `"a b`.
@lauft
Copy link
Member

lauft commented Mar 3, 2019

With the following example

#!/bin/bash

export TIMEWARRIORDB=/tmp/tiwmewarriordb
mkdir -p ${TIMEWARRIORDB}/data
rm -f ${TIMEWARRIORDB}/data/*.data
:> ${TIMEWARRIORDB}/timewarrior.cfg

src/timew start '"a'
src/timew stop

I get

Note: '"a' is a new tag.
Tracking "a
  Started 2019-03-03T15:48:36
  Current                  36
  Total               0:00:00
Trying to decrement non-existent tag '"a'

before and

Note: '"\"a"' is a new tag.
Tracking "\"a"
  Started 2019-03-03T15:47:52
  Current                  52
  Total               0:00:00
Trying to decrement non-existent tag '"a'

after applying your PR. I will have to investigate this before merging your PR.

@janikrabe
Copy link
Contributor Author

For future reference, these messages are from src/Database.cpp:113 and src/helper.cpp:111. Both of these call quoteIfNeeded. It might make sense to either remove the quoteIfNeeded for display purposes, or to remove the additional surrounding single quotes from the "new tag" message.

The issue with the non-existent tag is GothenburgBitFactory/libshared#14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants