Comments (5)
There is a secure problem in this plugin. (see #27 for the detail, thanks to jason0x90.) I have already merge the PR and republish it and send a email to wordpress team to reopen it. Please wait some times.
from wp-code-highlight.js.
Hi, it's been a month, do you know when they are adding it back?
from wp-code-highlight.js.
Sorry. The wordpress team tell me there are still some CSRF problems in this plugin when wordpress is setup for multiple sites. I don't use wordpress any more and I have no environment to test it after making a lot of changes to codes. So this plugin may be closed later.
from wp-code-highlight.js.
How about publishing the version that was updated after the fix from #27?
from wp-code-highlight.js.
Sorry, I have tried to publish it again but the wordpress team tell me I need to sanitize all data(Though I think I have sanitized all the input field.). I don't use wordpress myself any more and I have no environment to test this plugin. I seggust you to find another replacement or just import highlightjs's js and css into your website ,for example, add these codes below into the tail of <body></body>
:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/highlight.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/languages/bash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/languages/cpp.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/languages/go.min.js"></script>
<!--<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/languages/OTHER LANGUAGES.min.js"></script>-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/vs.min.css" />
And then add these codes to enable it:
<script type="text/javascript">
jQuery(function(){
hljs.configure({
tabReplace: ' ',
useBR: false,
classPrefix: '',
languages: []
});
jQuery('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
// add this if you need syntaxhighlighter compatible mode
jQuery('pre:not(:has(code))').each(function(i, block){
var class_desc = jQuery(block).attr("class") || "";
var reg_mat = class_desc.match(/brush\s*:\s*([\w\d]+)/i);
if(!reg_mat || reg_mat.length < 2)
return;
var code_content = jQuery(block).removeClass("brush:").removeClass("ruler:").removeClass("first-line:").removeClass("highlight:")
.removeClass("brush:" + reg_mat[1] + ";").removeClass(reg_mat[1] + ";").removeClass("true;").removeClass("false;").html();
jQuery(block).empty().append(jQuery("<code class='hljs'></code>").html(code_content)).addClass(reg_mat[1]);
hljs.highlightBlock(block);
});
// add this if you need prettify compatible mode
jQuery('pre.prettyprint:not(.prettyprinted), code.prettyprint:not(.prettyprinted), xmp.prettyprint:not(.prettyprinted)').each(function(i, block){
var jblock = jQuery(block).removeClass("prettyprint");
if (jblock.prop("tagName").toLowerCase() == "code" && jblock.parent().prop("tagName").toLowerCase() == "pre") {
hljs.highlightBlock(jblock.parent().get(0));
return;
}
var class_desc = jQuery(block).attr("class") || "";
var reg_mat = class_desc.match(/lang[^-]*-([\w\d]+)/i);
var code_content = jQuery("<code class='hljs'></code>");
if (reg_mat && reg_mat.length >= 2) {
code_content.addClass(reg_mat[1]);
}
if (jblock.prop("tagName") === "PRE") {
jblock.wrapInner(code_content);
hljs.highlightBlock(jblock.children().get(0));
} else {
var code_content = jblock.html();
jblock.replaceWith(jQuery("<pre></pre>").append(code_content.html(code_content)));
hljs.highlightBlock(jblock.get(0));
}
});
// add this if you need crayon compatible mode
jQuery('pre:not(:has(code))').each(function(i, block){
var class_desc = jQuery(block).attr("class") || "";
var reg_mat = class_desc.match(/lang\s*:\s*([\w\d]+)/i);
var code_content = jQuery("<code class='hljs'></code>").html(jQuery(block).removeAttr('class').html());
if (reg_mat && reg_mat.length >= 2) {
code_content.addClass(reg_mat[1]);
}
jQuery(block).empty().append(code_content);
hljs.highlightBlock(block);
});
});
</script>
If you use ES6 API instead of jQuery, you can also use window.addEventListener('DOMContentLoaded', () => { ... });
to replace jQuery(function(){ ... });
, document.querySelectorAll("...")
to replace jQuery selector, use forEach((block) => {...})
to replace jQuery.each(function(i, block) {...})
and etc.
from wp-code-highlight.js.
Related Issues (15)
- parser bug HOT 1
- Baidu CDN option does not work HOT 2
- "Nasty Hack" line 273 Breaks Plugin when content dir is not in the default place
- Could not parse BB-Tag HOT 2
- Should delete all the br tags which belong to BBCode HOT 1
- Cannot change style after 0.5.5 HOT 3
- Can't add code indentation in tinyMCE HOT 2
- 行号|复制 HOT 2
- markdown HOT 1
- Worpress 4.7.3 无法选择其他语言 HOT 3
- WP 4.7.4 class not added HOT 7
- Hooking into `wp_head` and not `wp_enqueue_scripts` HOT 2
- lines won't break? HOT 1
- 插件还更新不? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-code-highlight.js.