Closed Bug 566295 Opened 14 years ago Closed 13 years ago

when the editor load the html source code, it replace all < and > into html entity.

Categories

(Skywriter Graveyard :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: b.ponsero, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4
Build Identifier: < or > are replaced by &lt; and &gt; 

very bad when we have a code like this: 

if ( 123 < 1234)

bespin show :

if ( 123 &lt; 1234)


Reproducible: Always
Target Milestone: --- → 1.0
I can replicate this bug.
For me <, >, & (&lt;, &gt;, &amp;) are all replaced with their html entity equivalents.

My present solution, although terrible in that it breaks deliberately encoded elements, is the following:
// Javascript START
function isEncHTML(str) {
	if (str.search(/&amp;/g) != -1 || str.search(/&lt;/g) != -1 || str.search(/&gt;/g) != -1) { return true; }
	else { return false; }
}
function decHTMLifEnc(str){
	if (isEncHTML(str)) {
		return str.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>');
	}
	return str;
}
window.onBespinLoad = function() {
	bespin.useBespin("edit", { "stealFocus": true, "syntax": "php"}).then(
		function(env) {
			env.editor.value = decHTMLifEnc(env.editor.value);
		},
		function(error) {throw new Error("Launch failed: "+error); } 
	);
}
// Javascript END

Note the two html decoding functions which I borrowed from here: http://www.prodevtips.com/2008/10/21/jquery-plugin-html-decode-and-encode/
and the call to one of them in the useBespin().then()

My goal was to replace a live php/javascript editor I had been using personally in a textarea with one including syntax highlighting. Without Skywriter it works perfectly, when bringing Skywriter in to the picture as illustrated above it breaks editing on those three html entities. The workaround contained herein also breaks certain things but as this is a personal tool I know to work around it and it breaks them less often than current Skywriter behaviour.
ACETRANSITION

The Skywriter project has merged with Ajax.org's Ace project (the full server part of which is their Cloud9 IDE project). Background on the change is here:

http://mozillalabs.com/skywriter/2011/01/18/mozilla-skywriter-has-been-merged-into-ace/

The bugs in the Skywriter product are not necessarily relevant for Ace and quite a bit of code has changed. For that reason, I'm closing all of these bugs. Problems that you have with Ace should be filed in the Ace issue tracker at GitHub:

https://github.com/ajaxorg/ace/issues
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.