472,781 Members | 1,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,781 software developers and data experts.

WYSIWYG editor returning &gt; instead <

Howdy,

I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then
save it back to my SQL server using a SQLCommand, all HTML characters are
changed to HTML code, i.e. &gt;strong&lt; instead of <strong> and so on. Is
this a problem with the editor or something else? Does .Net convert it? I
had to disable page validate request because of the tags, is there more?

Thanks,

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com


Dec 1 '05 #1
4 2941
Hi David,

Welcome to ASPNET newsgroup.
Regarding on the HTML editor html text processing question, here are some
of my understanding and suggestion:

1. As for those WYSIWYG html editors , they should directly provide the
property to let us access the raw HTML value (edited at client) when being
postback to server... Also, we need to turn off asp.net page's
validateRequest first...... You can debug through the code in IDE to
explore the text provided by the 3rd party html editor you used to verify
this...

2. As for SqlCommand , it'll directly inserted the string parameter we
provided in sqlcommand's statement or parameter, there won't have any
automatic htmlencoding, we can verify the data stored in sqlserver through
the query analyzer.....

In addition, some html editor will provide a property like "EncodedHtml"
which is the value of the html which has been html encoded.... So I'd
suggest you verify the about things to see at what step is the raw HTML
value being converted by html encoding...

If there're anything unclear, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "David Lozzi" <Da********@nospam.nospam>
| Subject: WYSIWYG editor returning &gt; instead <
| Date: Thu, 1 Dec 2005 15:13:22 -0500
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <ec**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:362150
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Howdy,
|
| I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then
| save it back to my SQL server using a SQLCommand, all HTML characters are
| changed to HTML code, i.e. &gt;strong&lt; instead of <strong> and so on.
Is
| this a problem with the editor or something else? Does .Net convert it? I
| had to disable page validate request because of the tags, is there more?
|
| Thanks,
|
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|
|
|
|

Dec 2 '05 #2
Hi David,

Does my last reply helps a little? If there're anything else we can help,
please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| X-Tomcat-ID: 90707638
| References: <ec**************@TK2MSFTNGP12.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Fri, 02 Dec 2005 04:49:20 GMT
| Subject: RE: WYSIWYG editor returning &gt; instead <
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <8W**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 66
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:362240
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi David,
|
| Welcome to ASPNET newsgroup.
| Regarding on the HTML editor html text processing question, here are some
| of my understanding and suggestion:
|
| 1. As for those WYSIWYG html editors , they should directly provide the
| property to let us access the raw HTML value (edited at client) when
being
| postback to server... Also, we need to turn off asp.net page's
| validateRequest first...... You can debug through the code in IDE to
| explore the text provided by the 3rd party html editor you used to verify
| this...
|
| 2. As for SqlCommand , it'll directly inserted the string parameter we
| provided in sqlcommand's statement or parameter, there won't have any
| automatic htmlencoding, we can verify the data stored in sqlserver
through
| the query analyzer.....
|
| In addition, some html editor will provide a property like "EncodedHtml"
| which is the value of the html which has been html encoded.... So I'd
| suggest you verify the about things to see at what step is the raw HTML
| value being converted by html encoding...
|
| If there're anything unclear, please feel free to post here.
|
| Regards,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
|
|
|
| --------------------
| | From: "David Lozzi" <Da********@nospam.nospam>
| | Subject: WYSIWYG editor returning &gt; instead <
| | Date: Thu, 1 Dec 2005 15:13:22 -0500
| | Lines: 18
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-RFC2646: Format=Flowed; Original
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | Message-ID: <ec**************@TK2MSFTNGP12.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:362150
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Howdy,
| |
| | I'm using a WYSIWYG editor called TinyMCE. When I edit some text and
then
| | save it back to my SQL server using a SQLCommand, all HTML characters
are
| | changed to HTML code, i.e. &gt;strong&lt; instead of <strong> and so
on.
| Is
| | this a problem with the editor or something else? Does .Net convert it?
I
| | had to disable page validate request because of the tags, is there more?
| |
| | Thanks,
| |
| | --
| | David Lozzi
| | Web Applications Developer
| | dlozzi@(remove-this)delphi-ts.com
| |
| |
| |
| |
| |
|
|

Dec 6 '05 #3
It appears not to have anything to do with the SQL command. I am currently
just working with a file. My script opens the file and reads the html
between two tags <editArea> and </editArea>. The HTML between the two is
then loaded into the WYSIWIG editor and looks great!. When I click Save, it
writes back to the file with the incorrect text Instead of an > it writes
&gt; and <, &lt;.

If I set the save button to only load the data from the editor into another
plain non-rtf textarea everything looks good. the > are > and < are <. I
just tried to load the text file from the second textarea independant of the
WYSIWYG editor and all of the < > are still converting to &lt; &gt;. This
seems to be independant of the editor? My code is below to open the file,
maybe something there?

I typed in the following into my textarea:
<b>this is a test</b><br>

And got this on my HTML page:
<b>this is a test</b><br>

If I put this directly into the .Write() like below, it works correctly. I
see a bold sentence.
win.Write("<b>this is a test</b><br>")

Dim path As String = Server.MapPath("tester.aspx")

Dim din As New StreamReader(IO.File.OpenRead(path))

Dim conts As String = din.ReadToEnd

din.Close()

Dim start As String = Left(conts, InStr(conts, "<editArea>") + 9)

Dim midd As String = Textarea1.Value

Dim endf As String = Right(conts, Len(conts) - InStr(conts, "</editArea>") +
1)

Dim win As New StreamWriter(IO.File.OpenWrite(path))

win.Write(start & midd & endf)

win.Close()

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:8W**************@TK2MSFTNGXA02.phx.gbl...
Hi David,

Welcome to ASPNET newsgroup.
Regarding on the HTML editor html text processing question, here are some
of my understanding and suggestion:

1. As for those WYSIWYG html editors , they should directly provide the
property to let us access the raw HTML value (edited at client) when being
postback to server... Also, we need to turn off asp.net page's
validateRequest first...... You can debug through the code in IDE to
explore the text provided by the 3rd party html editor you used to verify
this...

2. As for SqlCommand , it'll directly inserted the string parameter we
provided in sqlcommand's statement or parameter, there won't have any
automatic htmlencoding, we can verify the data stored in sqlserver through
the query analyzer.....

In addition, some html editor will provide a property like "EncodedHtml"
which is the value of the html which has been html encoded.... So I'd
suggest you verify the about things to see at what step is the raw HTML
value being converted by html encoding...

If there're anything unclear, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "David Lozzi" <Da********@nospam.nospam>
| Subject: WYSIWYG editor returning &gt; instead <
| Date: Thu, 1 Dec 2005 15:13:22 -0500
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <ec**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:362150
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Howdy,
|
| I'm using a WYSIWYG editor called TinyMCE. When I edit some text and
then
| save it back to my SQL server using a SQLCommand, all HTML characters
are
| changed to HTML code, i.e. &gt;strong&lt; instead of <strong> and so on.
Is
| this a problem with the editor or something else? Does .Net convert it?
I
| had to disable page validate request because of the tags, is there more?
|
| Thanks,
|
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|
|
|
|

Dec 15 '05 #4
I think the behavior is by design and it is a good practice. You don't
want end users inserting < > into your database to read back out to
your aspx pages since they can insert a <script> block and execute some
javascript when you display this text from the database.

What needs to happen is that when you get the data out of the database
you pass it as a parameter to the HttpUtility.Server.HtmlDecode(your
data). This would convert it from &lt; to < .

Also, if you really want to save the < > in the database then you can
use the same static method to decode the &lt; &gt; before its inserted
into the database.

I hope things are much clearer now.

Dec 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
2
by: Francesco Moi | last post by:
Hello. I designed a form to edit some DataBase's fields. But some of these fields contain '&lt;' and '&gt;' characters. And these characters are '<' and '>' in HTML. So if want to edit these...
18
by: Timothy Casey | last post by:
Thanks in advance... =~= Timothy Casey South Australia worloq@iprimus.com.au Formerly: casey@smart.net.au
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
2
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node...
0
by: Tony | last post by:
I want to display the text of items in a bulletedlist on multiple lines, but I can't get it working. Here is a sample version of my code below: protected void blStaff_DataBound(object sender,...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
1
by: ismailc | last post by:
Hi, I need help please. Update system to to new version & moved on to .Net2 But now my code that worked in my .Net1 xslt does not work. .Net1 fine: <xsl:stylesheet...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.