summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_difflib.py
Commit message (Collapse)AuthorAgeFilesLines
* Revert "bpo-35603: Escape table header of make_table output that can cause ↵Serhiy Storchaka2019-01-021-9/+0
| | | | | potential XSS. (GH-11341)" (GH-11356) This reverts commit 78de01198b047347abc5e458851bb12c48429e24.
* bpo-35603: Escape table header of make_table output that can cause potential ↵Xtreak2018-12-291-0/+9
| | | | XSS. (GH-11341)
* bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381)Raymond Hettinger2018-04-051-0/+8
|
* bpo-32981: Fix catastrophic backtracking vulns (#5955)Jamie Davis2018-03-041-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Prevent low-grade poplib REDOS (CVE-2018-1060) The regex to test a mail server's timestamp is susceptible to catastrophic backtracking on long evil responses from the server. Happily, the maximum length of malicious inputs is 2K thanks to a limit introduced in the fix for CVE-2013-1752. A 2KB evil response from the mail server would result in small slowdowns (milliseconds vs. microseconds) accumulated over many apop calls. This is a potential DOS vector via accumulated slowdowns. Replace it with a similar non-vulnerable regex. The new regex is RFC compliant. The old regex was non-compliant in edge cases. * Prevent difflib REDOS (CVE-2018-1061) The default regex for IS_LINE_JUNK is susceptible to catastrophic backtracking. This is a potential DOS vector. Replace it with an equivalent non-vulnerable regex. Also introduce unit and REDOS tests for difflib. Co-authored-by: Tim Peters <tim.peters@gmail.com> Co-authored-by: Christian Heimes <christian@python.org>
* Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-6/+6
|
* #17445: difflib: add diff_bytes(), to compare bytes rather than strGreg Ward2015-04-211-1/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some applications (e.g. traditional Unix diff, version control systems) neither know nor care about the encodings of the files they are comparing. They are textual, but to the diff utility they are just bytes. This worked fine under Python 2, because all of the hardcoded strings in difflib.py are ASCII, so could safely be combined with old-style u'' strings. But it stopped working in 3.x. The solution is to use surrogate escapes for a lossless bytes->str->bytes roundtrip. That means {unified,context}_diff() can continue to just handle strings without worrying about bytes. Callers who have to deal with bytes will need to change to using diff_bytes(). Use case: Mercurial's test runner uses difflib to compare current hg output with known good output. But Mercurial's output is just bytes, since it can contain: * file contents (arbitrary unknown encoding) * filenames (arbitrary unknown encoding) * usernames and commit messages (usually UTF-8, but not guaranteed because old versions of Mercurial did not enforce it) * user messages (locale encoding) Since the output of any given hg command can include text in multiple encodings, it is hopeless to try to treat it as decodable Unicode text. It's just bytes, all the way down. This is an elaboration of a patch by Terry Reedy.
* Issue #2052: Add charset parameter to HtmlDiff.make_file().Berker Peksag2015-03-141-0/+35
|
* Issue 21635: Fix caching in difflib.SequenceMatcher.get_matching_blocks().Raymond Hettinger2014-06-211-0/+9
|
* Issue 11747: Fix output format for context diffs.Raymond Hettinger2011-04-121-2/+27
|
* Issue #11747: Fix range formatting in context and unified diffs.Raymond Hettinger2011-04-111-0/+16
|
* Issue 10534, difflib: tweak doc; test new SequenceMatcher instance ↵Terry Reedy2010-12-151-0/+17
| | | | attributes; avoid unneeded lists of SM.b2j keys and items in .__chain_b. Do not backport.
* Issue 2986: Add autojunk paramater to SequenceMatcher to turn off heuristic. ↵Terry Reedy2010-11-251-2/+43
| | | | Patch by Terry Reedy, Eli Bendersky, and Simon Cross
* Merged revisions 80004 via svnmerge fromR. David Murray2010-04-121-1/+23
| | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r80004 | r.david.murray | 2010-04-12 12:35:19 -0400 (Mon, 12 Apr 2010) | 13 lines Issue #7585: use tab between components in unified and context diff headers. Instead of spaces between the filename and date (or whatever the string is that follows the filename, if any) use tabs. This is what the unix 'diff' command does, for example, and difflib was intended to follow the 'standard' way of doing diffs. This improves compatibility with patch tools. The docs and examples are also changed to recommended that the date format used be the ISO 8601 format, which is what modern diff tools emit by default. Patch by Anatoly Techtonik. ........
* Merged revisions 76464 via svnmerge fromSenthil Kumaran2009-11-231-0/+8
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76464 | senthil.kumaran | 2009-11-24 00:11:31 +0530 (Tue, 24 Nov 2009) | 4 lines Fix for issue1488943 - difflib.Differ() doesn't always add hints for tab characters. ........
* Merged revisions 72979 via svnmerge fromPhilip Jenvey2009-05-281-6/+5
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r72979 | philip.jenvey | 2009-05-27 22:58:44 -0700 (Wed, 27 May 2009) | 2 lines explicitly close files ........
* #2621 rename test.test_support to test.supportBenjamin Peterson2008-05-201-1/+1
|
* PEP 3114: rename .next() to .__next__() and add next() builtin.Georg Brandl2007-04-211-2/+2
|
* Merge p3yk branch with the trunk up to revision 45595. This breaks a fairThomas Wouters2006-04-211-2/+6
| | | | | | | | | | | | | | | | | | | | number of tests, all because of the codecs/_multibytecodecs issue described here (it's not a Py3K issue, just something Py3K discovers): http://mail.python.org/pipermail/python-dev/2006-April/064051.html Hye-Shik Chang promised to look for a fix, so no need to fix it here. The tests that are expected to break are: test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecs test_multibytecodec This merge fixes an actual test failure (test_weakref) in this branch, though, so I believe merging is the right thing to do anyway.
* Patch #1413711: Certain patterns of differences were making difflibGustavo Niemeyer2006-01-311-0/+9
| | | | | touch the recursion limit. The applied patch inlines the recursive __helper method in a non-recursive way.
* Whitespace normalization. test_difflib passes again.Tim Peters2004-08-291-16/+16
|
* Reverting whitespace normalization. test_difflib fails with it -- theTim Peters2004-08-291-16/+16
| | | | | test depends on invisible trailing whitespace in .py files. The author will have to repair that.
* Whitespace normalization.Tim Peters2004-08-291-16/+16
|
* Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.Martin v. Löwis2004-08-291-2/+126
|
* SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generatorBrett Cannon2004-07-101-0/+7
| | | | | | that behaves as if both lists has an empty string in each of them. Closes bug #979794 (and duplicate bug #980117).
* Whitespace normalization.Tim Peters2004-01-181-1/+0
|
* Exercise Jim Fulton's new doctest extension for running doctests in aRaymond Hettinger2003-07-161-2/+5
| | | | | unittest environment. Since his extension finds docstrings in private functions, it exposed a bug in the difflib doctests.
* Fix SF bug #763023, difflib.py: ratio() zero division not caughtNeal Norwitz2003-07-011-0/+12
| | | | Backport candidate
* Get rid of relative imports in all unittests. Now anything thatBarry Warsaw2002-07-231-1/+2
| | | | | | | | | | | imports e.g. test_support must do so using an absolute package name such as "import test.test_support" or "from test import test_support". This also updates the README in Lib/test, and gets rid of the duplicate data dirctory in Lib/test/data (replaced by Lib/email/test/data). Now Tim and Jack can have at it. :)
* Teach regrtest how to pass on doctest failure msgs. This is done via aTim Peters2001-09-091-3/+2
| | | | | | | | | | | horridly inefficient hack in regrtest's Compare class, but it's about as clean as can be: regrtest has to set up the Compare instance before importing a test module, and by the time the module *is* imported it's too late to change that decision. The good news is that the more tests we convert to unittest and doctest, the less the inefficiency here matters. Even now there are few tests with large expected-output files (the new cost here is a Python-level call per .write() when there's an expected- output file).
* Remove test_doctest's expected-output file.Tim Peters2001-05-231-1/+2
| | | | | | Change test_doctest and test_difflib to pass regrtest's notion of verbosity on to doctest. Add explanation for a dozen "new" things to test/README.
* Remove test_difflib's output file and change test_difflib to stopTim Peters2001-05-231-1/+1
| | | | | generating it. Since this is purely a doctest, the output file never served a good purpose.
* Moved SequenceMatcher from ndiff into new std library module difflib.py.Tim Peters2001-02-101-0/+2
Guido told me to do this <wink>. Greatly expanded docstrings, and fleshed out with examples. New std test. Added new get_close_matches() function for ESR. Needs docs, but LaTeXification of the module docstring is all it needs. \CVS: ----------------------------------------------------------------------