initial import

This commit is contained in:
2025-06-22 20:39:04 -05:00
commit f8a70886f0
3428 changed files with 302546 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
From: Tomas Babej <tomas@tbabej.com>
Date: Sun, 24 Jan 2021 01:28:54 -0500
Subject: Lexer: Do not allow leading zero for number type
Lexer: Do not allow leading zero for two and more digit integers
tests: Add test for TW #2392
---
diff --git a/src/Lexer.cpp b/src/Lexer.cpp
index 461dace1..444588c8 100644
--- a/src/Lexer.cpp
+++ b/src/Lexer.cpp
@@ -608,7 +608,8 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type)
////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::number
-// \d+
+// 0
+// [1-9]\d*
// [ . \d+ ]
// [ e|E [ +|- ] \d+ [ . \d+ ] ]
// not followed by non-operator.
@@ -616,9 +617,16 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type)
{
std::size_t marker = _cursor;
+ bool leading_zero = (_text[marker] == '0');
+
if (unicodeLatinDigit (_text[marker]))
{
++marker;
+
+ // Two (or more) digit number with a leading zero are not allowed
+ if (leading_zero && unicodeLatinDigit (_text[marker]))
+ return false;
+
while (unicodeLatinDigit (_text[marker]))
utf8_next_char (_text, marker);
@@ -679,16 +687,24 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type)
////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::number
-// \d+
+// 0
+// [1-9]\d*
+// Integers do not start with a leading 0, unless they are zero.
bool Lexer::isInteger (std::string& token, Lexer::Type& type)
{
std::size_t marker = _cursor;
+ bool leading_zero = (_text[marker] == '0');
+
if (unicodeLatinDigit (_text[marker]))
{
++marker;
while (unicodeLatinDigit (_text[marker]))
utf8_next_char (_text, marker);
+
+ // Leading zero is only allowed in the case of number 0
+ if (leading_zero and marker - _cursor > 1)
+ return false;
token = _text.substr (_cursor, marker - _cursor);
type = Lexer::Type::number;

View File

@@ -0,0 +1,130 @@
From: Tomas Babej <tomas@tbabej.com>
Date: Sat, 30 Jan 2021 17:50:58 -0500
Subject: Backport parser issues fixes
This backports upstream PR #2405 and commit a5eee5f, which contain extra
fixes and tests for issues with numeric project names (amongst others)
which were being wrongly interpreted as expressions.
Addresses upstream issues TW-{2388,2386,2257,1908,1896}
---
diff --git a/src/CLI2.cpp b/src/CLI2.cpp
index ec2bd6c7..c49eb4d7 100644
--- a/src/CLI2.cpp
+++ b/src/CLI2.cpp
@@ -1277,7 +1277,9 @@ void CLI2::desugarFilterAttributes ()
A2 op ("", Lexer::Type::op);
op.tag ("FILTER");
- A2 rhs ("", values[0]._lextype);
+ // Attribute types that do not support evaluation should be interpreted
+ // as strings (currently this means that string attributes are not evaluated)
+ A2 rhs ("", evalSupported ? values[0]._lextype: Lexer::Type::string);
rhs.tag ("FILTER");
// Special case for '<name>:<value>'.
@@ -1371,7 +1373,7 @@ void CLI2::desugarFilterAttributes ()
// Do not modify this construct without full understanding.
// Getting this wrong breaks a whole lot of filtering tests.
- if (values.size () > 1 || evalSupported)
+ if (evalSupported)
{
for (auto& v : values)
reconstructed.push_back (v);
@@ -1946,6 +1948,41 @@ void CLI2::desugarFilterPlainArgs ()
}
////////////////////////////////////////////////////////////////////////////////
+// Detects if the bracket at iterator it is a start or end of an empty paren expression
+// Examples:
+// ( status = pending ) ( )
+// ^
+// it -----| => true
+//
+// ( status = pending ) ( project = Home )
+// ^
+// it -----| => false
+bool CLI2::isEmptyParenExpression (std::vector<A2>::iterator it, bool forward /* = true */) const
+{
+ int open = 0;
+ int closed = 0;
+
+ for (auto a = it; a != (forward ? _args.end (): _args.begin()); (forward ? ++a: --a))
+ {
+ if (a->attribute("raw") == "(")
+ open++;
+ else if (a->attribute("raw") == ")")
+ closed++;
+ else
+ // Encountering a non-paren token means there is something between parenthees
+ return false;
+
+ // Getting balanced parentheses means we have an empty paren expression
+ if (open == closed && open != 0)
+ return true;
+ }
+
+ // Should not end here.
+ return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an
// "and" operator inserted between them.
//
@@ -1971,10 +2008,18 @@ void CLI2::insertJunctions ()
// Insert AND between terms.
else if (a != prev)
{
- if ((prev->_lextype != Lexer::Type::op && a->attribute ("raw") == "(") ||
- (prev->_lextype != Lexer::Type::op && a->_lextype != Lexer::Type::op) ||
- (prev->attribute ("raw") == ")" && a->_lextype != Lexer::Type::op) ||
- (prev->attribute ("raw") == ")" && a->attribute ("raw") == "("))
+ if ((prev->_lextype != Lexer::Type::op &&
+ a->attribute ("raw") == "(" &&
+ ! isEmptyParenExpression(a, true) ) ||
+ (prev->attribute ("raw") == ")" &&
+ a->_lextype != Lexer::Type::op &&
+ ! isEmptyParenExpression(prev, false)) ||
+ (prev->attribute ("raw") == ")" &&
+ a->attribute ("raw") == "(" &&
+ ! isEmptyParenExpression(a, true) &&
+ ! isEmptyParenExpression(prev, false)) ||
+ (prev->_lextype != Lexer::Type::op &&
+ a->_lextype != Lexer::Type::op))
{
A2 opOr ("and", Lexer::Type::op);
opOr.tag ("FILTER");
diff --git a/src/CLI2.h b/src/CLI2.h
index f6b0ce94..025be4c8 100644
--- a/src/CLI2.h
+++ b/src/CLI2.h
@@ -99,6 +99,7 @@ private:
void findUUIDs ();
void insertIDExpr ();
void lexFilterArgs ();
+ bool isEmptyParenExpression (std::vector<A2>::iterator it, bool forward = true) const;
void desugarFilterPlainArgs ();
void insertJunctions ();
void defaultCommand ();
diff --git a/src/columns/ColTypeString.cpp b/src/columns/ColTypeString.cpp
index 37c1433d..4ef97578 100644
--- a/src/columns/ColTypeString.cpp
+++ b/src/columns/ColTypeString.cpp
@@ -58,7 +58,12 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
std::string domRef;
Lexer::Type type;
if (lexer.token (domRef, type) &&
- type == Lexer::Type::dom)
+ type == Lexer::Type::dom &&
+ // Ensure 'value' contains only the DOM reference and no other tokens
+ // The lexer.token returns false for end-of-string.
+ // This works as long as all the DOM references we should support consist
+ // only of a single token.
+ lexer.token (domRef, type) == false)
{
Eval e;
e.addSource (domSource);

81
task/PKGBUILD Normal file
View File

@@ -0,0 +1,81 @@
# Maintainer: Jesus E. <heckyel@riseup.net>
pkgname=task
pkgver=2.5.3
_debver=2.5.3
_debrel=4
pkgrel=1
pkgdesc="A command-line todo list manager"
arch=('i686' 'x86_64')
url="https://taskwarrior.org/"
license=('Expat')
depends=('util-linux' 'gnutls')
makedepends=('cmake' 'quilt')
optdepends=('bash-completion: for bash completion'
'python: for python export addon'
'ruby: for ruby export addon'
'perl: for perl export addon'
'perl-json: for perl export addon')
source=("https://taskwarrior.org/download/$pkgname-$pkgver.tar.gz"
"https://deb.debian.org/debian/pool/main/t/task/task_$_debver+dfsg-$_debrel.debian.tar.xz"
'0011-Lexer-Do-not-allow-leading-zero-for-number-type.patch'
'0012-Backport-parser-issues-fixes.patch')
sha512sums=('e906c8f42ad4b9a7e20a82defe31b89194d72957f18dd5129ecc41a2a60a9d8b0d01abb9b44ecce79b65cd9064af4a4a4c9dd695f98152e77908f130dc3f9677'
'64591722cd71e9d5dfa40747d2bf0b78af18694c6e4dcdcdc575ff305d8f7df1f3023646b1fef81c0a0bfc96e8d8964c12b2417829a8a2e1bb4cf7585f2a6eb9'
'47351e83fa286b0047fe8181cd8b4f4454efcf11b6d92c54d69fda8ee7419d7cba14affe860b02a0ee6305a5ded29d5de3e61b5357b676aeab8ec43fb9265fa8'
'23c6ab14652bf1304efc35b44ea4fb35363b843d1688ab27b20923ae2ffefd4e3a67cd0a3f7291ba9be0fa37dd725df1930ae63f545eb5bb3bfb26707c30a9cf')
prepare() {
cd "$srcdir/$pkgname-$pkgver"
if [[ ${pkgver%.*} = ${_debver%.*} ]]; then
# Debian patches
export QUILT_PATCHES=debian/patches
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
export QUILT_DIFF_ARGS='--no-timestamps'
mv "$srcdir"/debian .
# Doesn't apply and seems unimportant
rm -v debian/patches/0011-Lexer-Do-not-allow-leading-zero-for-number-type.patch || true
rm -v debian/patches/0012-Backport-parser-issues-fixes.patch || true
rm -v debian/patches/0013-Port-testsuite-to-python3.patch || true
rm -v debian/patches/005_tests-time-independent.patch || true
rm -v debian/patches/006_update-basetest-prefix.patch || true
rm -v debian/patches/008_fix_date_tests.patch || true
rm -v debian/patches/009_fix-test-exit-code.patch || true
quilt push -av
fi
# fix debian patches
patch -Np1 -i "$srcdir/0011-Lexer-Do-not-allow-leading-zero-for-number-type.patch"
patch -Np1 -i "$srcdir/0012-Backport-parser-issues-fixes.patch"
}
build() {
cd "$srcdir/$pkgname-$pkgver"
cmake -DCMAKE_INSTALL_PREFIX=/usr .
make
}
package() {
cd "$srcdir/$pkgname-$pkgver"
make DESTDIR="$pkgdir" install
# Note that we rename the bash completion script for bash-completion > 1.99, until upstream does so.
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/bash/task.sh" "$pkgdir/usr/share/bash-completion/completions/task"
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/fish/task.fish" "$pkgdir/usr/share/fish/vendor_completions.d/task.fish"
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/zsh/_task" "$pkgdir/usr/share/zsh/site-functions/_task"
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/vim/ftdetect/task.vim" "$pkgdir/usr/share/vim/vimfiles/ftdetect/task.vim"
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/vim/syntax/taskdata.vim" "$pkgdir/usr/share/vim/vimfiles/syntax/taskdata.vim"
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/vim/syntax/taskedit.vim" "$pkgdir/usr/share/vim/vimfiles/syntax/taskedit.vim"
install -Dm644 "$pkgdir/usr/share/doc/task/scripts/vim/syntax/taskrc.vim" "$pkgdir/usr/share/vim/vimfiles/syntax/taskrc.vim"
install -d "$pkgdir/usr/share/licenses/$pkgname"
for i in COPYING LICENSE; do
install -m644 "$i" -t "$pkgdir/usr/share/licenses/$pkgname"
done
}