Asked  7 Months ago    Answers:  5   Viewed   33 times

I have a site where users can post stuff (as in forums, comments, etc) using a customised implementation of TinyMCE. A lot of them like to copy & paste from Word, which means their input often comes with a plethora of associated MS inline formatting.

I can't just get rid of <span whatever> as TinyMCE relies on the span tag for some of it's formatting, and I can't (and don't want to) force said users to use TinyMCE's "Paste From Word" feature (which doesn't seem to work that well anyway).

Anyone know of a library/class/function that would take care of this for me? It must be a common problem, though I can't find anything definitive. I've been thinking recently that a series of brute-force regexes looking for MS-specific patterns might do the trick, but I don't want to re-write something that may already be available unless I must.

Also, fixing of curly quotes, em-dashes, etc would be good. I have my own stuff to do this now, but I'd really just like to find one MS-conversion filter to rule them all.

 Answers

79

HTML Purifier will create standards compliant markup and filter out many possible attacks (such as XSS).

For faster cleanups that don't require XSS filtering, I use the PECL extension Tidy which is a binding for the Tidy HTML utility.

If those don't help you, I suggest you switch to FCKEditor which has this feature built-in.

Wednesday, March 31, 2021
 
Alix
answered 7 Months ago
85

Pass it into a dummy call to preg_match(), and see if it returns false (indicating an error)?

Note:: Depending on where you intend this application to be run, I would question the decision to allow users to do this. You could be setting yourself up for a denial-of-service attack; all a malicious user needs to do is provide an incredibly long, complicated regex string, and your server will grind to a halt.

Wednesday, March 31, 2021
 
antoniputra
answered 7 Months ago
49

Encoding is not a variable: $this->Encoding

Saturday, May 29, 2021
 
huhushow
answered 5 Months ago
40

It does indeed work (as well as it can). You will need to use the "paste from Word" button, though, so TinyMCE can filter any of the extraneous markup that Word adds to its content. You'll also have to make sure the paste plugin (which is part of the the default install) is loaded.

I believe that you'll need to explicitly add the button in your theme, though. Take a look at this example from the TinyMCE wiki.

plugins : "paste",
theme_advanced_buttons3_add : "pastetext,pasteword,selectall",

will add the plugin and button (to whichever row you'd like). The TinyMCE wiki claims paste does Word filtering by default, but I've never seen it work in the wild without explicitly using the "paste from Word" button.

Thursday, July 29, 2021
 
Chvanikoff
answered 3 Months ago
99

You can keep the same renderer for different scenes. The renderer does not care what scene it will render. You can supply a different Scene everytime you call render() if you like.

// instantiate only once and keep it
var renderer = new THREE.WebGLRenderer();

// current scene and camera. Switch whenever you like
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(...);
fillScene(scene);

// rendering always uses current scene
function render() {
    renderer.render(scene, camera);
    requestAnimationFrame(render);
}

/* ... 
 *   somewhere in your application
 * ...
 */
if(condition) {
  // switch scene
  scene = new THREE.Scene();
  fillOtherScene(scene);
}
Tuesday, September 14, 2021
 
bart.z33
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :