summaryrefslogtreecommitdiff
path: root/test/libapt/strutil_test.cc
Commit message (Collapse)AuthorAgeFilesLines
* Forbid negative values in unsigned StrToNum explicitlyDavid Kalnischkies2021-02-031-0/+56
| | | | | | | strtoul(l) surprises us with parsing negative values which should not exist in the places we use to parse them, so we can just downright refuse them rather than trying to work with them by having them promoted to huge positive values.
* Don't parse \x and \0 past the end in DeEscapeStringDavid Kalnischkies2021-02-031-0/+6
| | | | | | This has no attack surface though as the loop is to end very soon anyhow and the method only used while reading CD-ROM mountpoints which seems like a very unlikely attack vector…
* Fix incorrect base64 encoding due to int promotionDavid Kalnischkies2021-02-031-0/+4
| | | | | | | For \xff and friends with the highest bit set and hence being a negative value on signed char systems the wrong encoding is produced as we run into undefined behaviour accessing negative array indexes. We can avoid this problem simply by using an unsigned data type.
* Add a simple test for APT::String::DisplayLengthDavid Kalnischkies2021-02-031-0/+17
| | | | | References: 2497198e9599a6a8d4d0ad08627bcfc7ea49c644 Gbp-Dch: Ignore
* Allow prefix to be a complete filename for GetTempFileDavid Kalnischkies2020-05-181-2/+2
| | | | | | | | | | | | | Our testcases had their own implementation of GetTempFile with the feature of a temporary file with a choosen suffix. Merging this into GetTempFile lets us drop this duplicate and hence test more our code rather than testing our helpers for test implementation. And then hashsums_test had another implementation… and extracttar wasn't even trying to use a real tempfile… one GetTempFile to rule them all! That also ensures that these tempfiles are created in a temporary directory rather than the current directory which is a nice touch and tries a little harder to clean up those tempfiles.
* Prevent GTest from flooding us with compiler warningsDavid Kalnischkies2018-05-041-12/+12
| | | | | | | | | | | | | | GTest has a bunch of undefined macros which causes the compiler to spit out warnings for each one on each test file. There isn't much we can do, so we just disable the warning for the testcases. Other warnings like sign-promo and sign-compare we can avoid by being more explicit about our expected integer constants being unsigned. As we are just changing testcases, there is no user visible change which would deserve to be noted in the changelog. Gbp-Dch: Ignore Reported-By: gcc-8
* support multiline values in LookupTagDavid Kalnischkies2017-12-131-0/+42
| | | | | | | | | | LookupTag is a little helper to deal with rfc822-style strings we use in apt e.g. to pass acquire messages around for cases in which our usual rfc822 parser is too heavy. All the fields it had to deal with so far were single line, but if they aren't it should really produce the right output and not just return the first line. Error messages are a prime candidate for becoming multiline as at the moment they are stripped of potential newlines due to the previous insufficiency of LookupTag.
* Reformat and sort all includes with clang-formatJulian Andres Klode2017-07-121-1/+1
| | | | | | | | | | | | | This makes it easier to see which headers includes what. The changes were done by running git grep -l '#\s*include' \ | grep -E '.(cc|h)$' \ | xargs sed -i -E 's/(^\s*)#(\s*)include/\1#\2 include/' To modify all include lines by adding a space, and then running ./git-clang-format.sh.
* tests: silence -Wmissing-declarationsDavid Kalnischkies2016-09-011-1/+1
| | | | | Gbp-Dch: Ignore Reported-By: gcc -Wmissing-declarations
* avoid std::get_time usage to sidestep libstdc++6 bugDavid Kalnischkies2016-06-171-0/+35
| | | | | | | | | | | | | | | | As reported upstream in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71556 the implementation of std::get_time is currently not as accepting as strptime is, especially in how hours should be formatted. Just reverting 9febc2b238e1e322dce1f94ecbed46d595893b52 would be possible, but then we would reopen the problems fixed by it, so instead I opted here for a rewrite of the parsing logic which makes this method a lot longer, but at least it provides the same benefits as the rewrite in std::get_time was intended to give us and decouples us from the fix of the issue in the standard library implementation of GCC. LP: 1593583
* accept only the expected UTC timezones in date parsingDavid Kalnischkies2016-05-281-0/+38
| | | | | | | | | | | | | | | | | | HTTP/1.1 hardcodes GMT (RFC 7231 §7.1.1.1) and what is good enough for the internet must be good enough for us™ as we reuse the implementation internally to parse (most) dates we encounter in various places like the Release files with their Date and Valid-Until header fields. Implementing a fully timezone aware parser just feels too hard for no effective benefit as it would take 5+ years (= until LTS's are out of fashion) until a repository could use non-UTC dates and expect it to work. Not counting non-apt implementations which might or might not only want to encounter UTC here as well. As a bonus, this eliminates the use of an instance of setlocale in libapt. Closes: 819697
* encode UTF-8 characters correctly in QuoteStringDavid Kalnischkies2015-11-051-0/+11
| | | | | | | Limit the field length to a char to avoid bogus FF for utf-8 characters with the default length. Closes: 799123
* reimplement the last uses of sprintfDavid Kalnischkies2015-04-101-0/+22
| | | | | | | | Working with strings c-style is complicated and error-prune, so by converting to c++ style we gain some simplicity and avoid buffer overflows by later extensions. Git-Dch: Ignore
* rewrite ReadMessages()David Kalnischkies2014-10-261-0/+70
| | | | | | | | | | | | | Central methods of our infrastructure like this one responsible for communication with our methods shouldn't be more complicated then they have to and not claim to have (albeit unlikely) bugs. While I am not sure about having improved the first part, the bug is now gone and a few explicit tests check that it stays that way, so nobody will notice the difference (hopefully) – expect that this should a very tiny bit faster as well as we don't manually proceed through the string. Git-Dch: Ignore
* add test for Basic Authentication schemeDavid Kalnischkies2014-10-231-1/+15
| | | | Git-Dch: Ignore
* Merge branch 'debian/sid' into debian/experimentalMichael Vogt2014-09-231-0/+15
|\ | | | | | | | | | | | | | | | | Conflicts: apt-pkg/acquire-item.cc apt-pkg/acquire-item.h apt-pkg/cachefilter.h configure.ac debian/changelog
| * strip everything spacey in APT::String::StripDavid Kalnischkies2014-09-071-0/+15
| | | | | | | | Git-Dch: Ignore
* | Only allow "apt-get build-dep path" when path starts with ./ or /Michael Vogt2014-07-081-0/+9
|/ | | | | | This avoid the subtle problem that someone might have a directory with the same package name as the build-depends he/she is trying to fetch. Also print a note that the specific file/dir is used.
* fix SubstVar to be usable as a replace_all methodDavid Kalnischkies2014-06-181-0/+35
| | | | | | | The name suggests that it is supposed to substitute a variable with a value, but we tend to use it in a more liberal replace_all() fashion, but this breaks if either of the parameters is empty or more importantly if two "variable" occurrences follow each other directly.
* use Google C++ Testing Framework for libapt testsDavid Kalnischkies2014-04-161-81/+57
| | | | | | | | | | | | My commit 45df0ad2 from 26. Nov 2009 had a little remark: "The commit also includes a very very simple testapp." This was never intended to be permanent, but as usually… The commit adds the needed make magic to compile gtest statically as it is required and links it against a small runner. All previous testcase binaries are reimplemented in gtest and combined in this runner. While most code is a 1:1 translation some had to be rewritten like compareversion_test.cc, but the coverage remains the same.
* cleanup headers and especially #includes everywhereDavid Kalnischkies2014-03-131-1/+6
| | | | | | | | Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use)
* warning: unused parameter ‘foo’ [-Wunused-parameter]David Kalnischkies2014-03-131-1/+1
| | | | | Reported-By: gcc -Wunused-parameter Git-Dch: Ignore
* add "APT::String::Endswith" and automatic adding of ".list" in apt edit-sourceMichael Vogt2013-11-291-0/+18
|
* change maxsplit default from "0" to maxintMichael Vogt2013-10-011-0/+4
|
* add maxsplit parameter to StringSplitMichael Vogt2013-09-071-0/+6
|
* implement StringSplit() as we need this to fix the dpkg status-fd output parsingMichael Vogt2013-09-071-0/+17
|
* do not pollute namespace in the headers with using (Closes: #500198)David Kalnischkies2011-09-191-1/+1
|
* add another escape test case, fixup octal one (its \0XX instead of \0XXX)Michael Vogt2011-07-261-0/+6
|
* * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc:Michael Vogt2011-07-261-0/+40
- add new DeEscapeString() similar to DeQuoteQuotedWord but unescape charackter escapes like \0XXX and \xXX (plus add test)