i made a website and i want to send mail to user.
i use url routing and if i use like this
localhost:1186/activate/johndoe#john.doe.com
i got iis server error because of dot signs. but if i don't use like this i can not get this email address from browser fully.
i want that special chars in this email address must convert to html entities .
# sign .(dot) sign and all of it .
i want use it but not work
string email = "johndoe#john.doe.com";
string nemail = HttpUtility.UrlEncode(email);
it returns like
johndoe%40john.doe.com
but it must return like this
johndoe%40john(dotsignconvertedchars)doecom
not convert to dot signs ...
help me
i think after urlencodeing why dont you replace all dots with what ever you want for eg
nemail.Replace(".","(dot)");
which would give you johndoe%40john(dot)com
then after reciving it replace back
nemail=nemail.Replace("(dot)",".");
nemail=HttpUtility.UrlDecode(nemail);
Related
Problem:-I want to validate an email id text box..I want to block Gmail id users
Eg:-
abcd#yahoo.com =>Ok
abcd#xmail.com =>Ok
abcd#hotmail.com =>Ok
abcd#gmail.com =>Not Ok
If any user entering Gmail id in the text box..the error msg will appear..??
already tried using
\w+([-+.']\w+)*#(?:gmail).com
But it Used for selecting only Gmail ids..I want negation of this..
Change (?: ) to (?! ) to match if content of ( ) is not present:
\w+([-+.']\w+)*#(?!gmail).com
This will not match abcd#gmail.com, but will fail also on abcd#yahoo.com because no other characters allowed between # and .com
To keep gmail.com blocked and to allow other domains change pattern to
\w+([-+.']\w+)*#((?!gmail\.com).*)
Note that when you have [-+.'] you tell to allow -,+,. and ' in the email address. Minus and dots are allowed but not plus and apostrophe.
So, finally
\w+([-.]\w+)*#((?!gmail\.com).*)
I think you can use negation of that
\w+([-+.']\w+)*#(?:gmail).com
In an if block check the email using this and take the negation..I think it will work
Try below regular expression:
\b[\w\.-]+#((?!gmail).)[\w\.-]+\.\w{2,4}\b
I am working on a URL filtering project . I have a database given to me which contain URLs need to be blocked (eg: a.b.com/d/e).
I get uri and domain from http request. I compare what I get with my database and redirect users without any problem. So far so good.
Problems starts with urls that contains query string and other magics with URL. As an example if user enters a.b.com/d/e?junk. What I get won't match with my database, and users will bypass my filter and they will still be able to go a.b.com/d/e.
I tried some useless actions like slicing everything after special chars like "?,#". But having problems with url like : youtube.com/watch?v=12vh55_1ul8, which becames like youtube.com/watch and blocks all youtube. That solution causes me more problems.
Now I am very confused how to handle this problem. Is there any guide or any library which I can use in C++ ?
Try this code:
string str (get_requsted_uri());
string str2 ("http://getaroundfilters.com/article/889/proxy");
if (str.find(str2) != string::npos) {
block();
} else {
get_and_return_webpage(str);
}
I am using the RegEx "^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*#[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+[.])*(\.[a-zA-Z]{2,17})$"to validate Email but my lead want to validate as per the Microsoft standard. SO i need to follow
http://msdn.microsoft.com/en-us/library/01escwtf(v=vs.100).aspx
In that everything working fine as per the standard but still i am facing the issues with
Valid: js#internal#proseware.com
Valid: j_9#[129.126.118.1]
the above mentioned mail ID is still returning as invalid. I tried using the regex used in that page
^(?("")(""[^""]+?""#)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])#))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$
but i am getting the error in the server page. Though I pasted the expression inside the validation Expression it can't able to accept the characters.
Note : am using ASP.Net validators for validating the email.
Description
To match both of those email addresses in your sample text, I think I would rewrite your expression like this:
[A-Z0-9._%#+-]+#(?:[A-Z0-9.-]+\.[A-Z]{2,4}|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\])
If you're looking to use this to validate a string which may contain only an email then you can add the start/end of string anchors ^ and $.
Example
Live Demo
Sample Text
Valid: js#internal#proseware.com Valid: j_9#[129.126.118.1]
Matches
[0][0] = js#internal#proseware.com
[1][0] = j_9#[129.126.118.1]
Hello i need a way to find out the host part of an url , i've tried
Request.Url.Host.Split('.')
but it doesn't work with url like this:
sub.sub.domain.com
or
www.domain.co.uk
since you can have a variable number of dots before and after the domain
i need to get only "domain"
Check out the second answer at Get just the domain name from a URL?
I checked the pastebin link; it's active. I didn't test the code myself, but if it outputs as he describes, you can .split() from there.
If you need to be totally flexibel, you need to make a list of all possible top-level-domains, and try to remove those, with dot, from the end of your string, resulting in
www.domain
or
sub.sub.domain
Then take the last characters after the last dot.
I have an encrypted query string passed from another page, it reads something like "/se73j+sef" but after receiving it, the '+' sign got omitted and became "/se73j sef". Is this normal? Please kindly advice. Thanks.
Is this normal?
Yes, perfectly normal. + is a special character in an url. It means space (0x20 ASCII character). If you want to represent the + sign you will have to url encode it:
/se73j%2Bsef
To url encode a string in .NET you could use the UrlEncode method. Or depending on how you are building the url there are certainly better ways.