Bug #7059
closedWhen built with gcc-8 RelWithDebInfo, adds "display: block" to some elements with changed tag names
0%
Description
To reproduce:
- Clone Wt into a subfolder
wtof the location ofbug.cppandCMakeLists.txt(checkout tag 4.0.5) -
mkdir build && cd build -
cmake .. && make -
./bugdemo --docroot . --http-listen 127.0.0.1:8080 - Point a browser at
localhost:8080 - Inspect the text element
Expected result:
<nav id="someId" class="navbar>
<span id="someOtherId">Bug demo</span>
</nav>
Actual result:
<nav id="someId" class="navbar style="display: block;">
<span id="someOtherId">Bug demo</span>
</nav>
This only happens when built with gcc-8 in CMake's default RelWithDebInfo config. If you do cmake .. -DCMAKE_BUILD_TYPE=Debug so that it instead builds libwtd.so, the bug does not happen. If you build with gcc-9, the bug does not happen.
From my investigation, the root of the issue seems to be in DomElement.isDefaultInline. This is called from WWebWidget.updateDom and the extra display: block is added if it returns true. In the case of this <nav> element, its type is DomElementType::OTHER, whose ordinal is 51, and we look in defaultInline_ at that index for an answer, but that array has only 50 elements. When built in any of the "good" configurations, defaultInline_[51] evaluates to false. When built in the "bad" configuration, it evaluates (on my system) to 97, i.e. true.
Seems to me like two "easy" fixes would be
- Add two more
falseelements ontodefaultInline_to bring its size in line with the number ofDomElementTypes - In
isDefaultInline, check ifstatic_cast<unsigned int>(type) > 49and just return false if so
But I'm not sure what the other implications of that might be.
Note: In my own project, I've seen this happen in 2 places: a WContainerWidget whose tag name was changed to "nav" (like in my example), and a WTemplateFormView whose tag name was changed to "form". Other elements have changed tag names but do not exhibit this behavior.
Files
Updated by Roel Standaert over 6 years ago
- Status changed from New to Resolved
That should indeed not cause an array out of bounds access.
I made it so it takes the default inline of the standard DOM element type of the widget (see commit 6bf929b)
Updated by Roel Standaert over 6 years ago
- Status changed from Resolved to Closed