Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

HTML and chrs issues

(Page 1 of 2)
> >
Quote Reply
HTML and chrs issues
Hi,

Is there a way of automatically ensure that text entered into Description and Details pages does not contain html code or chrs that could potentially mess up XML feeds (like © • </> " and many others)?
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
Yes. In the table editor (Database > Links/Properties) click the column you wish to modify (so "Description" in this case) and then in the "Regex" field enter the regex you want to use.

So to allow letters, numbers, underscores, spaces and periods only, use:

^[\w\.\s]+$

Last edited by:

Paul: Dec 14, 2002, 9:04 AM
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Thanks Paul - will other chrs then just be ignored, deleted or will the editor get an error message?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
There will be an error message.
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

I was wondering if you could help me with the regex for the following

A phone number that should be entered as:
+971(4)343434

- first bit is country code and can vary in lenght
- city code in between brackets - not always requited
- last bit max 10 digits

Cheers
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
Off the top of my head...

Code:
^\+\d{2,4}(?:\(\d\))?\d{6,10}$

That makes a couple of assumptions. First it assumes that country code are between 2 and 4 digits long. If they aren't just change it as required.

We don't have city codes so I don't know how long they are so I've just allowed for one digit like in your example.

Then the final bit allows 6 to 10 digits in length.

Last edited by:

Paul: Feb 17, 2003, 7:02 AM
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Perfect - thanks Paul :-)

Only thing is - entering a phone number is Not required - and I get an error if I leave the field blank... is there a way around this (I have set it not Not Null - No) but still get the error

Thanks in advance

Finally - is this workable for e-mail varification?
^\S+@\S+\.\S+$


Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
Try this:

Code:
^|\+\d{2,4}(?:\(\d\))?\d{6,10}$

Yes that regex is ok for loose email verification.
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

Now it allows anything to pass - I inserted the | as you suggested, but now the rest of the regex is ignored..?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
It should allow a blank entry or a valid phone number - can you just enter junk and it lets it through?

Last edited by:

Paul: Feb 17, 2003, 7:40 AM
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

I tried with "xlfjghfjkghdfkjg" and it passes...?!?

This is what I use:
^|\+\d{2,4}(?:\(\d{0,4}\))?\d{6,10}$

I tried the same for e-mail:
^|\S+@\S+\.\S+$

In both cases I can pass any junk now...

It should not be a blank anyway - it should be that the field is empty...

Any ideas?
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
My bad. Before the | add:

(?:

and before the $ add:

)
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Thanks Paul - that did it :-)

http://www.ameinfo.com
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

Is there a way to set a minimum number of chrs in a field using regex?

Ex. The field is not required - but if you enter something it should be at least 3 chrs and only be non-compromising chrs..

Pushing my luck here - but something like:

^(?:|[\w\.\s]{3,})+$

- trying to learn how to put these things together - do you have any resource for this to learn more?

Klaus

http://www.ameinfo.com

Last edited by:

klauslovgreen: Feb 17, 2003, 1:25 PM
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

Need your help again I'm afraid...

I use:
Code:
^(?:|\+\d{2,4}(?:\(\d{0,4}\))?\d{6,10})$

But I need to allow a space if there is no citycode...


Ex. I need to allow both the following:
+971(2)666666

and

+971 666666

Can you help?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
Try:

Code:

^(?:|\+\d{2,4}(?:\(\d{0,4}\)|\s{0,1})\d{6,10})$
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Thanks a million Paul - perfect!

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
Quote:
Is there a way of automatically ensure that text entered into Description and Details pages does not contain html code or chrs that could potentially mess up XML feeds (like © • </> " and many others)?

A little late on this, but if your doing this because of the XML plugin, you may want to look at:

http://www.gossamer-threads.com/...i?post=221689#221689

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

Need your help again.. (not sure this can be done though..)

I need a regex that check a date is valid:

yyyy-mm-dd

I then have two date entries - a Start_Date and and End_Date - can I then have a regex that ensures that End_Date is equal or later than Start_Date

Cheers
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
*bump*

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
Hi,

For checking the dates I'd use GT::Date - if you click the help link in the admin panel I think you will find the appropriate documentation.

As for the regex, try:

/^\d{4}-\d\d-\d\d$/

...that will check the formatting but won't check for valid dates.
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Thanks Paul - I saw the documentation - my problem it how do I call it? Should I have a global or..?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
How are the dates entered?..is it done by the user on the add/modify page?
Quote Reply
Re: [Paul] HTML and chrs issues In reply to
Hi Paul,

Yes on the add/modify page bu the user - so basically I need add.cgi and modify.cgi to report an error if End_Date is equal to or before Start_Date - something like "The event can't have an End_Date before the Start_Date..

I also noticed I can use something like date_is_valid to ensure that it is a date that makes sense (ie. you should not be able to use a Start_Date prior to today's date) - but I am not sure that's how date_is_valid works...

Any suggestions are welcomed..

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] HTML and chrs issues In reply to
You'd probably need a plugin for this and hook user_add_link with a PRE/LAST hook.
> >