Skip to content
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

> getting transformed to > #159

Closed
jaydeepbasu opened this issue Jul 23, 2020 · 10 comments · Fixed by #187
Closed

> getting transformed to > #159

jaydeepbasu opened this issue Jul 23, 2020 · 10 comments · Fixed by #187
Labels
[Pri] Normal [Status] Queued In the queue of issues to work on next. [Type] Bug

Comments

@jaydeepbasu
Copy link

jaydeepbasu commented Jul 23, 2020

Using SyntaxHighlighter Evolved plugin when adding <plugin>abcd</plugin> in blog it is rendering as <plugin&gt;abcd</plugin&gt;
Using latest version of wordpress and the plugin.

@alexsanford
Copy link
Contributor

Looks like this is a duplicate of #108

I haven't been able to reproduce this, so there is something we're missing here. A few questions:

  • Are you using the block editor, or the classic editor with shortcodes?
  • If using the block editor, what are the Block settings? What "Code Language" is selected?
  • If using shortcodes, which shortcode and options are you using?
  • Have you tried with all other plugins on the site disabled?

@jaydeepbasu
Copy link
Author

I am using Block Editor, as I was putting xml in the block so the language is set to HTML/XML and no other settings apart from that.
I am only using JetPack plugin.
I haven't tried by disabling the JetPack plugin as that plugin is mandatory for me.
Any suggestions?

@alexsanford
Copy link
Contributor

Hmmm. I just spun up a fresh site with only Jetpack, using the Twenty Twenty theme, and this is what I see on the frontend:

Screen Shot 2020-07-24 at 10 27 28

What theme are you using? Could you test with Twenty Twenty and see whether that changes anything?

Here's what my block settings look like. Anything look different for you?

Screen Shot 2020-07-24 at 10 30 03

@jaydeepbasu
Copy link
Author

Though I might sound illogical but I am no longer facing the issue, I have done no version upgrade,not a single change but it is working now. Yesterday I installed the plugin for the first time and when i faced the issue I tried all possible ways to correct it but it didn;t work, 12 hours after that it started working.
Request you to please keep it open, in case i face it again, i can update here in comment.

@alexsanford
Copy link
Contributor

It's better to close this issue at this point, since it is not a reproducible bug. But comments will still be open, and the issue can be reopened if the bug comes up again, so please feel free to give any new information if that happens 🙂

@l2m83
Copy link

l2m83 commented Oct 1, 2020

Hello,
We had a similar problem, it seems that it occured for users that are not administrator (ex: Editor).

@coreymckrill
Copy link

I've discovered a way to consistently reproduce this issue:

  • Set up a multisite installation of WordPress, install the SyntaxHighlighter plugin.
  • Create two users on the site, a super admin and an editor.
  • With each user, publish a post with a SyntaxHighlighter block that contains <?php echo 'Hello World'; ?>
    and has the code language set to PHP.
  • With each post, change the editor settings from Visual Editor to Code Editor. You'll see that they both appear to contain the same content within the block grammar: &lt;?php echo 'Hello World'; ?>
  • Now view each post on the front end. The one published by the super admin will look correct, while the one published by the editor will have this: <?php echo 'Hello World'; ?&gt;

I believe this happens because on multisite, non-admins do not have the unfiltered_html capability, as suggested by @jrastaban here. So when the editor user publishes the post, what actually gets stored in the database is &lt;?php echo 'Hello World'; ?&gt;.

It looks like this commit might actually fix the issue, but it hasn't been released yet. Will confirm as soon as I get the src files to build correctly...

coreymckrill added a commit that referenced this issue Dec 4, 2020
…e encoded and output by the render callback

I believe this will address the issues described in #108 and #159. At first I thought I would just add `$code = str_replace( '&gt;', '>', $code );` as a third line of "Undo escaping...", but then I figured it would potentially catch more edge cases to just decode all HTML entities at this point in the code. They get re-encoded later in the `shortcode_callback` method, so this helps further prevent double-encoding.
@coreymckrill
Copy link

^ That commit didn't fix the issue when I tested, so I opened #182.

@yscik
Copy link
Contributor

yscik commented Jan 18, 2021

Still happening on master with non-admin roles.

@yscik yscik reopened this Jan 18, 2021
@yscik yscik added [Status] Queued In the queue of issues to work on next. and removed [Status] Needs Author Reply labels Jan 18, 2021
@l2m83
Copy link

l2m83 commented Jan 20, 2021

@coreymckrill, in addition to str_replace try calling htmlspecialchars_decode
$code = str_replace( '<', '<', $code );
$code = htmlspecialchars_decode( $code );

The modification was done on our wordpress installation and it seems to do the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Pri] Normal [Status] Queued In the queue of issues to work on next. [Type] Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants