Closed Bug 57104 Opened 25 years ago Closed 25 years ago

Text incorrectly interpreted as a url. (Regex error)

Categories

(Other Applications Graveyard :: ChatZilla, defect, P3)

x86
Linux

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: mozilla, Assigned: rginda)

References

Details

Overview Description: Text with the characters "www..." is incorrectly interpreted as a url. Steps to Reproduce: 1. Start ChatZilla and join a channel. 2. Type "www..." 3. Observe Actual Results: The text is converted to a link. Expected Results: No link. Reproducibility: everytime Build Date & Platform Bug Found: Mozilla/5.0 (X11; U; Linux 2.2.16-3 i686; en-US; m18) Gecko/20001012 Additional Builds and Platforms Tested On: none Additional Information: I believe the relevant code is http://lxr.mozilla.org/seamonkey/source/extensions/irc/xul/content/static.js#204 obj.munger.addRule ("link", /((\w+)\:\/\/[^\<\>\(\)\'\"\s]*|www\.[^\<\>\(\)\'\"\s]+\.[^\<\>\(\)\'\"\s]*)/, insertLink);
CC Hixie to see if he wants to have some regex fun. :)
Found this nice little regex on the NLUG list archives. Maybe it would be of some use. #!/usr/bin/perl while (<>) { if (($service,$user,$password,$host,$port,$file,$params,$anchor)=(/^(?:([a-zA-A ]+)\:\/\/)?(?:([A-Za-z0-9\_\.\-]*?)(?:\:([A-Za-z0-9\_\.\-]*?))?\@)?([a-zA-Z0 -9\.\_\-]*?)(?:\:([0-9]{1,5}))?(\/.*?)?(?:\?(.*?))?(?:#(.*?))?$/)) { print "Service: ${service}\nUser: ${user}\nPassword: ${password}\n"; print "Host: ${host}\nPort: ${port}\nFile: ${file}\n"; print "Params: ${params}\nAnchor: ${anchor}\n\n"; } else { print "I don't recognize this as a URL.\n"; } }
I don't think so. D:\CVS\104\mozilla\themes\classic\communicator\mac>echo www.cnn.com | perl -e "while (<>) {if (($service,$user,$password,$host,$port,$file,$params,$anchor)=(/^(?:([a-zA-A]+) \:\/\/)?(?:([A-Za-z0-9\_\.\-]*?)(?:\:([A-Za-z0-9\_\.\-]*?))?\@)?([a-zA-Z0-9\.\_ \-]*?)(?:\:([0-9]{1,5}))?(\/.*?)?(?:\?(.*?))?(?:#(.*?))?$/)) {print qq(Service: ${service}\nUser: ${user}\nPassword: ${password}\n);print qq(Host: ${host}\nPort: ${port}\nFile: ${file}\n);print qq(Params: ${params}\nAnchor: ${anchor}\n\n);} else {print qq(I don't recognize this as a URL.\n);}}" I don't recognize this as a URL. according to a survey of people i respect .. nullifises domain names my quick fix: obj.munger.addRule ("link", /((\w+)\:\/\/[^\<\>\(\)\'\"\s]*|www\.[^.\<\>\(\)\'\"\s]+\.[^.\<\>\(\)\'\"\s]*)/ , insertLink);
Can we fix this while we're at it? we match "www.foo.com" but not "www.foo.co.uk". For that matter, we match "www.foo."... Also, you do not need to backwack metachars in character classes. /((\w+):\/\/[^<>()'"\s]+|www(\.[^.<>()'"\s]+){2,})/ but preferably: /((\w+):\/\/[^<>()'"\s]+|www(\.[-\w]+){2,})/ If the parens and choice of // as delimiters are not necessary I'd drop them for readability's sake.
i'm thinking about the following: www|ftp [.{text}]* .\w\w\w? ie, ftp.mozilla.co, ftp.mozilla.com, not ftp.mozilla.come this catches all countries, and current tlds. of course i'll need to fit this into the current scheme.
Depends on: 57633
fix checked in
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Verified with 2000120808 linux build.
Status: RESOLVED → VERIFIED
Product: Core → Other Applications
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.