Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2005-08-13 09:02:34

kptkip
Xinha Community Member
Registered: 2005-08-13
Posts: 14

Convert Special Chars into HTML-equivalent

Hi folks,

I have recognized, that xinha doesn't change special chars like the german umlauts into their HTML-Equivalent.

Is there a config-flag to switch on this very basic feature?

Especially because all Editors produce HTML-Tags into the Editors-field there is no possibility to clean this with a general cleaning function in the CMS like htmlentities() in PHP. Otherwise all HTML-Tags are masked also.

Because of this it is really neccessary that special chars are already switched in the editor.

Does anybody know, how to realize it?

Greetings
Kpt|Kip

P.S.
There is also a problem with writing code into the Editor, if you want to show something like this
"This is an Anker-tag: <a href="sdfsdf">erfgergt.</a>"
it is impossible

Last edited by kptkip (2005-08-13 10:18:04)

Offline

#2 2005-08-13 11:05:49

mharrisonline
Xinha Administrator
From: Denver, Colorado
Registered: 2005-04-11
Posts: 110
Website

Re: Convert Special Chars into HTML-equivalent

Ticket 127 probably shows how you can add this ability to Xinha.

http://xinha.python-hosting.com/ticket/127

Offline

#3 2005-08-13 11:26:28

kptkip
Xinha Community Member
Registered: 2005-08-13
Posts: 14

Re: Convert Special Chars into HTML-equivalent

There's a problem with this topic.

First: my script didn't work at all after this implementation, like you can read there with other guys also.
Second: I dont believe that a Character-Type-Changing is helping in this topic.

To solve this Problem you need to convert ä to "ä" not to something like this "/ä/g".

I think that is not the right way to solve this - unfortunately.

By the way I dont understand, that not everybody has Problems with this. Because even writing code into the Editor doesn't work, not only the crazy german umlauts.

Ok so long!
Kpt|Kip

Offline

#4 2005-08-13 11:30:01

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Convert Special Chars into HTML-equivalent

kptkip wrote:

Hi folks,

I have recognized, that xinha doesn't change special chars like the german umlauts into their HTML-Equivalent.

xinha_config.sevenBitClean = true;

will approximatly do what you require, presuming you are using utf-8 encoding for Xinha (infact even if you're not it will probably do what you need).


There is also a problem with writing code into the Editor, if you want to show something like this
"This is an Anker-tag: <a href="sdfsdf">erfgergt.</a>"
it is impossible

I have not seen this behaviour, can anybody confirm?


James Sleeman

Offline

#5 2005-08-13 11:58:22

kptkip
Xinha Community Member
Registered: 2005-08-13
Posts: 14

Re: Convert Special Chars into HTML-equivalent

I have solved the problems with the Umlauts on my own - I extended the htmlEncode-function for them.

But there is also now the Problem with Code-Tags.
An Example:

I write the following text into the Editor:

lkjfböjäsfbüsfgbä
fkgbäß
<span style="background-color:#ff6d33">dfgfghjdfgjäkj</span>
sfgbägä

If i switch to the HTML-View there is the following code:

<p>
<span style="text-decoration: underline;"></span></p><p>lkjfböjäsfbüsfgbä</p><p>fkgbäß</p><p>
<span style="background-color:#ff6d33">dfgfghjdfgjäkj</span>
 </p><p>sfgbägä<br />
</p>

So it seems everything is ok. After saving the content to the DB the output from the CMS is correct. So the masked characters are saved in the DB and the Output is wonderful!


But after re-reading the Data into the Editor you can see the follwing code in the HTML-View:

<p>
<span style="text-decoration: underline;"></span></p><p>lkjfböjäsfbüsfgbä</p><p>fkgbäß</p><p>
<span style="background-color: rgb(255, 109, 51);">dfgfghjdfgjäkj</span> 
</p><p>sfgbägä<br /></p>

Offline

#6 2005-08-13 12:13:13

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Convert Special Chars into HTML-equivalent

Sounds like you are not entizing the data you put between the <textarea> tags.  As per the HTML standards, <textarea> content is #PCDATA.  That means you must not put "raw html" in it, you must run it through an entizer, such as in php, htmlspecialchars()

<textarea><?php echo htmlspecialchars($myhtmltoedit) ?></textarea>

James Sleeman

Offline

#7 2005-08-13 12:30:25

kptkip
Xinha Community Member
Registered: 2005-08-13
Posts: 14

Re: Convert Special Chars into HTML-equivalent

Hm that seems to be strange.

When the content is read out of the DB there is the conent entitized: there is ">" and not ">".

If i entitize them again you'll get &gt; is this correct?

Greetings
Kpt|Kip

Offline

#8 2005-08-14 01:26:53

mharrisonline
Xinha Administrator
From: Denver, Colorado
Registered: 2005-04-11
Posts: 110
Website

Re: Convert Special Chars into HTML-equivalent

How did you preserve the German HTML entities, if you didn't add  str = str.replace(/ä/g, "ä"); to htmlEncode to convert the lowercase ä to ä?

Offline

#9 2005-08-14 02:54:06

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Convert Special Chars into HTML-equivalent

If you want the Xinha area to display (in HTML mode)

<hello & world>

then your textarea would look like

<textarea>&lt;hello &amp; world&gt;</textarea>

This is the correct format as per HTML specifications - <textarea> has no valid tags that may appear in it and the content is defined as #PCDATA


James Sleeman

Offline

#10 2005-08-14 05:42:37

kptkip
Xinha Community Member
Registered: 2005-08-13
Posts: 14

Re: Convert Special Chars into HTML-equivalent

Hi gogo!

I have found the Problem.

I did it like you mentioned:

<textarea><? echo htmlspecialchars($MyString); ?></textarea>

And now it works ;-) thnx for your help!

Now there is another problem :-):
Like in an parallel thread I mentioned I have problems with ImageManager and the Linker. They produce links and src's like:

After saving and reloading the complete beginning until the first "/" has gone. Afterwards it looks like:

test.html

How can I solve this?

Greetings
Kpt|Kip

Offline

#11 2005-08-14 22:28:42

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Convert Special Chars into HTML-equivalent

Try playing with these settings

  // specify a base href for relative links
  this.baseHref  = null;

  // we can strip the base href out of relative links to leave them relative, reason for this
  //   especially if you don't specify a baseHref is that mozilla at least (& IE ?) will prefix
  //   the baseHref to any relative links to make them absolute, which isn't what you want most the time.
  this.stripBaseHref = true;

  // and we can strip the url of the editor page from named links (eg <a href="#top">...</a>)
  //  reason for this is that mozilla at least (and IE ?) prefixes location.href to any
  //  that don't have a url prefixing them
  this.stripSelfNamedAnchors = true;

(eg xinha_config.stripBaseHref = false; )


James Sleeman

Offline

#12 2005-08-15 10:21:58

kptkip
Xinha Community Member
Registered: 2005-08-13
Posts: 14

Re: Convert Special Chars into HTML-equivalent

Hi gogo!

I have tried this:

xinha_config.stripBaseHref = false;            
xinha_config.baseHref  = null;                    
xinha_config.stripSelfNamedAnchors = false;

But it doesnt work at all. Even wired combinations of baseURL+stripBaseHref and Anchors

I have seen the same thing in the htmlarea.js. even if I switch it of ("false") at this point - no reaction.

is there another way to stop this?

Greetings Alex

Offline

Board footer

Powered by FluxBB