CacheReadString() took the length of a string straight from the .cached
file and passed len - 1 to wxCharBuffer. A stored length of 0 underflowed
to SIZE_MAX, so wxCharTypeBuffer allocated (SIZE_MAX + 1) bytes, i.e.
none, and then wrote its terminator at str[SIZE_MAX], which wraps on
64-bit to a write one byte in front of the block. The buffer was also a
byte shorter than the read that filled it, so the terminator was
overwritten and the wxString constructor went looking for one past the
end, and a large or negative length asked for a huge allocation or a read
through a null pointer.
Size the buffer as len so the terminator survives the read, as
ReadString() in zipstrm.cpp already does, reject a length that cannot
have come from CacheWriteString() or that exceeds the file, check the
read actually delivered the bytes, and build the string from the known
length rather than by scanning for a NUL.
The contents and index counts are used to reserve memory before anything
is read, so bound them against the file as well, and move the contents
loop to std::make_unique so the new early returns cannot leak, as the
index loop already does.
Fixes#26765.
Closes#26766.
Track the active DL nesting depth while parsing definition lists and
use it when indenting DD content, so nested definition lists are laid
out deeper than their parent item. Add parser coverage and a sample
case for the old nested DL repro.
Fixes#20752.
Closes#26676.
Preserve non-breaking spaces in wxHtmlWinParser instead of converting them
to normal spaces, and prevent wxHtmlWordCell from allowing a line break
before NBSP-only text segments.
Add a parser regression test covering an -only segment between words.
Fixes#20399.
Closes#26678.
Store BODY BGCOLOR in the wxHTML parser state even when there is no
window interface, then carry the parsed colour onto the renderer root
cell so wxHtmlDCRenderer fills printed pages with it instead of white.
Add a renderer regression test covering BODY BGCOLOR output.
Fixes#20652.
Closes#26677.
Apply TABLE ALIGN to the wrapper that positions the table instead of
using it as the default alignment for TD/TH content. Leave cell text
alignment controlled by row/cell alignment, with the existing TH default.
Add a parser layout regression test and sample markup for the centered
table case.
Fixes#21853.
Closes#26672.
Capture the current text metrics when parsing image cells and use them to
position ALIGN=CENTER images relative to the surrounding text center and
not to the total cell height.
Add a parser regression test for the image and adjacent word vertical
centers.
Fixes#2976.
Closes#26669.
LoadCachedBook reads each index entry's parent back-reference straight
from the .cached file and uses it as an index with no check, so a
crafted cached file (which can sit inside a .htb help archive opened
through AddBook) may result in creating a pointer to data outside the
m_index array; that pointer is later dereferenced when the index is
sorted at the end of AddBookParam.
The change rejects the file when parentShift is negative or larger than
the number of index entries loaded so far, matching the existing version
and flags checks just above.
Also add a small test under tests/html that feeds such a cached stream
and confirms it is now refused rather than reading out of bounds.
Closes#26577.
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.
Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.
And also use null in the assert messages.
Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
Remove the unnecessary, and actually harmful, overridden GetProduct(),
as we must delete the pointer returned by the base class version to
avoid leaking it.
Also use wxScopedPtr to avoid leaking a test wxHtmlContainerCell.
For some reason, the height of a text line is 15px there and not 18px as
locally, so 400px high image still fit on the second page in the last
test. Make it higher to ensure that it doesn't.
Set the "printer" PPI explicitly for wxMemoryDC used in the test to
ensure that it's the same in all ports: currently wxGTK3 stands out
because it uses 72 DPI unlike wxMSW and wxGTK2, which use 96.
The standard margins, expressed in millimeters, could result in the
usable page space being much smaller than 1000px used for the DC size
when using higher DPIs, which means that the test checking that a 2400px
image took only 3 pages could fail, as it could require 4 of them in
this case.
Fix this by getting rid of the margins, as this should ensure that the
page height is exactly 1000px now, independently of the actual DPI.
Destroying a window with mouse capture results in an assert, which is
translated into an exception when running the test suite. As this exception is
thrown from wxWindowBase dtor, it results in an immediate program termination
when using C++11 and can also have the same effect even when using C++98 if
this exception is thrown while already handling another exception due to a
test failure.
Try to avoid this by using a "safe" DeleteTestWindow() function instead of
deleting the window directly. Currently this function ensures that the window
doesn't have mouse capture before deleting it, but it could also be used to
check for other things later. Also, this commit only uses this function for
the two controls which do happen to be destroyed with mouse capture currently
(at least when using wxGTK), but it should probably be generalized to all
controls in the future.
Use wxHtmlWinParser instead of wxHtmlParser which can't be actually used
without being initialized with the tag handlers (it's not clear whether this
is really intentional...).
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.
If nothing else, this will make an eventual transition to Git simpler.
Closes#14487.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Use the same short names as are used by the event table macros for the event
type constants themselves. This makes them much more comfortable to use, e.g.
Bind(wxEVT_BUTTON) compared to Bind(wxEVT_COMMAND_BUTTON_CLICKED).
The old long names are still kept for backwards compatibility and shouldn't be
removed as it doesn't really cost anything to continue providing them, but all
new event types should only use the short versions.
Closes#10661.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73850 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
The code in wxHtmlParser supposed in many places that a '<' character must be
always followed by a '>' one and could create (and sometimes dereference)
invalid iterators if this wasn't the case resulting in asserts from MSVC debug
CRT and possibly crashes.
Fix this by ensuring that only valid iterators are used and add a trivial unit
test for wxHtmlParser which checks that it can parse invalid HTML without
crashing.
Closes#12869.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Add a lot of tests for many wx GUI classes.
Add tests using the new wxUIActionSimulator class but disable them under OS X
as too many of them currently fail there.
Refactor the test suite to make organizing the existing tests and adding the
new ones easier.
Improve documentation using the information gathered while testing the
classes. Also update the documentation of the testing system itself.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775