473,395 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Quotes in HTML snippets

Hi group,

I've set up an agenda-like system where "admins" can enter upcoming
events, including a description of the event. This description can
include HTML formatting and is entered in a <textarea>.

The problem I'm facing is this: suppose an "admin" enters a description,
but one of the attributes of a HTML tag doesn't have a closing double
quote.
An example:

<div class="summarydiv>
Short admin-written summary of the event...
</div>

Now, they submit the event. The page that lists the events just picks
this description up from the database and puts it in a <ul> list. Of
course, the unmatched quote causes _all_ subsequent HTML code to be
considered part of the description, until by chance a next double quote
is encountered. You can imagine this gives horrible and unpredictable
results for the news page.

I'm thinking of a few possibilities to solve this:
* some sort of a regex check on the description, before it is submitted
to the DB
* simply counting the number of double quotes between < > delimiters,
the number should be even
* ...?

What do you experts think? Any suggestions?

Thanks in advance,
Wald
Jul 17 '05 #1
1 1866
wald wrote:
I've set up an agenda-like system where "admins" can enter upcoming
events, including a description of the event. This description can
include HTML formatting and is entered in a <textarea>.
OT: forget "HTML formatting" -- there's no such thing.
The problem I'm facing is this: suppose an "admin" enters a description,
but one of the attributes of a HTML tag doesn't have a closing double
quote.
[ ... ]
I'm thinking of a few possibilities to solve this:
* some sort of a regex check on the description, before it is submitted
to the DB
AIUI regular expressions alone can't accomplish that.
* simply counting the number of double quotes between < > delimiters,
the number should be even
No, that won't work either. There's no requirement in HTML for a
start-tag to contain an even number of double quotes.

[ ... ]
What do you experts think? Any suggestions?


I suggest you reconsider interpreting the data as HTML. What happens
when a naughty "admin" (I suppose the quotes are necessary) enters
<IMG src="http://domain.example/rudepic">?

If you insist though, consider using a parser to catch those syntax
errors; apparently HTML Tidy, http://www.w3.org/People/Raggett/tidy/ ,
can flag missing quote marks. Catching semantic mistakes might be
harder.

Have a great weekend sir!

--
Jock
Jul 17 '05 #2

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

Similar topics

6
by: Cyrus D. | last post by:
Hi guys, I haven't done that much research on this topic but it seems I can use either the single quotes or the double quotes. SInce I am so used to C(++) I prefer the double quotes and am...
8
by: Christoph Zwerschke | last post by:
I sometimes use triple quotes in order to produce snippets of multiline code, like that: if output == html: snip = '''<html> <head><title>Hello, World</title></head> <body...
7
by: duwayne | last post by:
I have a problem of escaping quotes in javascript. Ex: onclick='alert( "Mister O'Hara" )' onclick='alert( "Mister O\'Hara" )' both gives me an error. How would I escape this?
4
by: cjm | last post by:
I have two problems that I suspect will be bread-and-butter problems for the more experienced guys on here, but I'm not the greatest with js. NB: Code snippets at the bottom The first problem...
11
by: Ron | last post by:
Hello, I'm having an aggravating time getting the "html" spewed by Word 2003 to display correctly in a webpage. The situation here is that the people creating the documents only know Word, and...
7
by: Tim Mulholland | last post by:
I have an issue i can work around, but i'm trying to figure out what i'm "supposed" to do. i have a line of HTML/ASP.NET code inside a repeater that is something like this <a...
1
by: desi.american | last post by:
I have a dynamically generates ASPX page with tables and data. Depending on user selection, the same page can be viewed as a simple web page (rendered in HTML) or as an excel spreadsheet. If the...
37
by: Ian Rastall | last post by:
I've been working on an online books site for almost four years now, and have been putting smart quotes in each book. This is a major hassle, and I'm beginning to think it's not worth it. Is...
7
by: skunkwerk | last post by:
Hi, i'm trying to call subprocess.popen on the 'rename' function in linux. When I run the command from the shell, like so: rename -vn 's/\.htm$/\.html/' *.htm it works fine... however when I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.