Page MenuHomePhabricator

doBlockLevels inserts pre-tags in a text created by an extension
Closed, DeclinedPublic

Description

Author: chmarndt

Description:
The extension I wrote creates a table and inserts a
<script> ... </script> section. However, it does not
work as the call of the doBlockLevel-function destroys the
structure, see

<p><script type="text/javascript">
</p><p> ...
</p><p> </script>
</p><p>

Therefore, I placed the doBlockLevel-function directly after
the internalParse-function. Having this done, the extension works.

However, does this lead to any side effects?


Version: 1.20.x
Severity: normal
See Also:
T68495: MathML elements are filtered out on betalabs

Details

Reference
bz1319
TitleReferenceAuthorSource BranchDest Branch
add LICENSE and a notice in the README.mdrepos/releng/gitlab-webhooks!11brennenreview/brennen/licensemain
local.json: update footer links for foundation wikirepos/phabricator/deployment!4brennenfooter-updateswmf/stable
Use node16 for freshrepos/releng/cli!379addshorefresh-node-16main
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 8:08 PM
bzimport set Reference to bz1319.
bzimport added a subscriber: Unknown Object (MLST).

jeluf wrote:

Our experience is that changing the order or parser steps always breaks something.
I'd recommend to escape the javascript by replacing it by a "cookie" that is
replaced by
the real java script at the end of the processing. See Parser::strip() for how
we do this.

Parser::strip() is precisely the function that is used in the given example. It
is broken, because unstrip() is done before doBlockLevels().

The reason Gabriel put doBlockLevels() last, after unstrip(), is because he wanted the output to be valid XHTML. That means not having block-level elements inside other block-level elements. doBlockLevels() will automatically detect nested block-level elements, and will break up the outer one to produce valid HTML.

The solution I suggested, in private discussion years ago, is to have doBlockLevels() scan the stripped HTML for block-level elements, and if they are present, to treat the strip marker as a block-level element. Then the resulting string can be unstripped to produce valid XHTML.

  • Bug 1772 has been marked as a duplicate of this bug. ***
  • Bug 8997 has been marked as a duplicate of this bug. ***
  • Bug 27906 has been marked as a duplicate of this bug. ***

The workaround for this problem is to replace newlines in the text that your extension is feeding to the parser with a space. This is what extensions currently do.

This behavior is very unlikely to change since some extensions might rely on it.

Declining per last comment.