-
Notifications
You must be signed in to change notification settings - Fork 384
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
Code in <pre> elements breaks things #613
Comments
Note I am using the WP-Syntax plugin. I tried disabling it, but it seems to have no bearing on this problem. |
The linked post is validating properly with the |
This is not about validation. Did you look at the post in AMP and regular versions? |
Oh, I see; I thought that the "breaking HTML" was a validation issue. Will look into this in more detail. |
Sorry I didn’t describe it better. Seems like the shell redirect |
I’m installed via Wordpress, but if you give me a patch I’m happy to give it a test if needed. |
A quick check you could do is to download the plugin from GitHub and put it into your plugins directory; change the name of the plugin in amp.php so that it appears as a different plugin. Activate it and check your post. If that works, then the issue is the with the version of in Wordpress.org; we need to address this: #720 |
Plugin has been updated! |
Just updated through Wordpress, still having the same problem. This is on version 0.5. |
Hi @miken32, I am testing a post with that sample |
Well I've confirmed it's not cached by updating the post, and syntax highlighting is still disabled. I put up a short test post with this content:
|
Got it; don't know what is happening. Re-opening the issue to track the problem. |
Without AMP it get's output as: <div class="wp_syntax" style="position:relative;"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">tee</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>foo<span style="color: #cc0000; font-style: italic;"><<'EOF'
bar
EOF</span></pre></td></tr></table><p class="theCode" style="display:none;">#!/bin/bash
tee /tmp/foo<<'EOF'
bar
EOF</p></div> With AMP active, however, it is output as: <div class="wp_syntax">
<table><tr><td class="code"><pre class="bash amp-wp-inline-6e55cd5874e142e710268c63a0bf1d5b"><span class="amp-wp-inline-cfd229d4d7837d4ff4f01c73f4645495">#!/bin/bash</span>
<span class="amp-wp-inline-91a3a813b7013bff7d5e41b8b31980af">tee</span> <span class="amp-wp-inline-1e2d3daaad6014ca7a9a9dedd183a25c">/</span>tmp<span class="amp-wp-inline-1e2d3daaad6014ca7a9a9dedd183a25c">/</span>foo<span class="amp-wp-inline-26fd8fecc327ebd0565339da3370cc99"><<'EOF'
bar
EOF</span></pre></td></tr></table>
<p class="theCode">#!/bin/bash
tee /tmp/foo<<'EOF'
bar
EOF</p>
</div> Notice how the |
The problem is the use of This is what is removing the
The problem is that To be like this: add_filter( 'safe_style_css', '__return_empty_array', PHP_INT_MAX );
$string = safecss_filter_attr( esc_html( $string ) );
remove_filter( 'safe_style_css', '__return_empty_array', PHP_INT_MAX ); |
@coreymckrill Any objections? |
My problem has nothing to do with CSS, unless you're talking about some internal intermediate rendering. Without AMP:
AMP:
|
I was testing specifically in the 0.7-beta version with for a theme that has If I test in 0.6 with in the existing post templates I do see what you do: The problem is that If I change that line to: if ( did_action( 'wp_print_scripts' ) || ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ) { Then it outputs: Here you get styling, but you can see it reproduces the issue I noted above with regard to the So I think there are two fixes: (1) WP Syntax plugin needs to fix the condition for whether to do the parsing, and (2) the AMP plugin needs to fix how it handles the In regards specifically to So it should be: Some plain text.
<pre lang="bash">
#!/bin/bash
tee /tmp/foo<<'EOF'
bar
EOF
</pre>
More plain text. It may be an accident that |
There is no raw |
I see raw |
@westonruter Been a long time since I dug into this. What would be the security implications of not running inline style declarations through a safelist? It seems like that could lead to arbitrary strings being output in a style block. Could the bug be fixed by adding more allowed attributes instead of causing it to skip the process entirely? |
Yeah there is a raw |
@miken32 do you have the WP Syntax plugin active? It needs to be fixed if it is going to be used here.
@coreymckrill The logic in |
@westonruter Ah, ok. No objections, then. 👍 |
I have the following in a post:
This breaks the resulting AMP HTML; which ends up looking like this:
Some plain text.
You can see this demonstrated here: https://mike.eire.ca/2016/07/08/running-freepbx-with-nginx/amp/
The text was updated successfully, but these errors were encountered: