Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate .tld for new feed URLs #325

Merged
merged 3 commits into from
Nov 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions client/reader/following-edit/subscribe-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var FollowingEditSubscribeForm = React.createClass( {

handleKeyDown: function( event ) {
// Use Enter to submit
if ( event.keyCode === 13 && this.state.searchString.length > minSearchLength && this.state.isWellFormedFeedUrl ) {
if ( event.keyCode === 13 && this.state.searchString.length > minSearchLength && this.state.isWellFormedFeedUrl ) {
event.preventDefault();
this.handleFollowToggle();
}
Expand Down Expand Up @@ -98,11 +98,16 @@ var FollowingEditSubscribeForm = React.createClass( {
},

isWellFormedFeedUrl: function( parsedUrl ) {
if ( parsedUrl.hostname && parsedUrl.hostname.indexOf( '.' ) !== -1 ) {
return true;
if ( ! parsedUrl.hostname || parsedUrl.hostname.indexOf( '.' ) === -1 ) {
return false;
}

return false;
// Check for a valid-looking TLD
if ( parsedUrl.hostname.lastIndexOf( '.' ) > ( parsedUrl.hostname.length - 3 ) ) {
return false;
}

return true;
},

render: function() {
Expand Down