-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carousel: issues modifying markup in some environments #13531
Comments
When are we looking for I ask because the
I'm not sure that $dom->loadHTML( '<style>foo</style><div class="hello">', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD );
var_dump( $dom->saveHTML() ); // <style>foo<div class="hello"></div></style> So we should provide a root element, and we should probably make up a fake type of element to protect against losing content if the input is broken in peculiar ways. Perhaps something like: $tag = "jetpack-" . mt_rand( 10000, 99999 );
$dom->loadHTML( "<$tag>$html</$tag>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD );
…
return substr( trim( $dom->saveHTML() ), strlen( $tag ) + 2, -1 * ( strlen( $tag ) + 3 ) );
Part of the problem is that we're using this one function (
For 1, we could run the function, then remove the closing tag. For 2, we can just run the function as is.
|
This issue has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation. |
Edit, this might not be super useful after all: #13547 (comment) seems like the encoding needs to be known up front? I recently had to figure something similar out for the block pattern translation stuff we've been doing, this snippet is possibly useful.
I think you'd still need to close off and then unclose that div in one of the cases but that should be able to work the same way as the html/body wrap. There may be more to this, I'm not completely sure about the contexts of use here but it's certainly a similar case. |
Following #13446 (reverted in #13564), I'm seeing some issues in some environments, where:
https://stackoverflow.com/a/44866403/1045686 There is also quite a bit in the comments here: https://www.php.net/manual/en/domdocument.savehtml.php
div
tag we're editing (we are adding a new attribute) also gets autoclosed.I'll need to revise my implementation to take this into account. Here is a summary of the current problems:
https://stackoverflow.com/q/58096669/1045686
I may have to give up on using
DOMDocument
here after all.Noting that this is happening on WordPress.com for example, so this is blocking D32610-code.
Original issue: #13428
Related: #13604
The text was updated successfully, but these errors were encountered: