Replace noPeriod attribute in JSON file with a regexCheck attribute. If this does not exist in the JSON file, then there will be a default regular expression that will be used. By default, the allowed user name pattern requires that the first character is alphabetic, while the following characters are either alphanumeric or ".", "_", or "-". Also, specifically indicate that the user name is invalid in the feedback.

pull/16/head
Christopher K. Hoadley 6 years ago
parent cb62daa557
commit 4067991b59

@ -21,7 +21,7 @@
"Blogger": { "Blogger": {
"url": "https://{}.blogspot.com", "url": "https://{}.blogspot.com",
"errorType": "status_code", "errorType": "status_code",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"Google Plus": { "Google Plus": {
"url": "https://plus.google.com/+{}", "url": "https://plus.google.com/+{}",
@ -40,7 +40,7 @@
"GitHub": { "GitHub": {
"url": "https://www.github.com/{}", "url": "https://www.github.com/{}",
"errorType": "status_code", "errorType": "status_code",
"noPeriod": "True" "regexCheck": "^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$"
}, },
"Steam": { "Steam": {
"url": "https://steamcommunity.com/id/{}", "url": "https://steamcommunity.com/id/{}",
@ -67,7 +67,7 @@
"DeviantART": { "DeviantART": {
"url": "https://{}.deviantart.com", "url": "https://{}.deviantart.com",
"errorType": "status_code", "errorType": "status_code",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"VK": { "VK": {
"url": "https://vk.com/{}", "url": "https://vk.com/{}",
@ -165,13 +165,13 @@
"url": "https://www.kongregate.com/accounts/{}", "url": "https://www.kongregate.com/accounts/{}",
"errorType": "message", "errorType": "message",
"errorMsg": "Sorry, no account with that name was found.", "errorMsg": "Sorry, no account with that name was found.",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"LiveJournal": { "LiveJournal": {
"url": "https://{}.livejournal.com", "url": "https://{}.livejournal.com",
"errorType": "message", "errorType": "message",
"errorMsg": "Unknown Journal", "errorMsg": "Unknown Journal",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"VSCO": { "VSCO": {
"url": "https://vsco.co/{}", "url": "https://vsco.co/{}",
@ -191,7 +191,7 @@
"url": "https://dribbble.com/{}", "url": "https://dribbble.com/{}",
"errorType": "message", "errorType": "message",
"errorMsg": "Whoops, that page is gone.", "errorMsg": "Whoops, that page is gone.",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"Codecademy": { "Codecademy": {
"url": "https://www.codecademy.com/{}", "url": "https://www.codecademy.com/{}",
@ -215,7 +215,7 @@
"Newgrounds": { "Newgrounds": {
"url": "https://{}.newgrounds.com", "url": "https://{}.newgrounds.com",
"errorType": "status_code", "errorType": "status_code",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"Wattpad": { "Wattpad": {
"url": "https://www.wattpad.com/user/{}", "url": "https://www.wattpad.com/user/{}",
@ -251,7 +251,7 @@
"url": "https://{}.contently.com/", "url": "https://{}.contently.com/",
"errorType": "message", "errorType": "message",
"errorMsg": "We can't find that page!", "errorMsg": "We can't find that page!",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"Houzz": { "Houzz": {
"url": "https://houzz.com/user/{}", "url": "https://houzz.com/user/{}",
@ -306,7 +306,7 @@
"Slack": { "Slack": {
"url": "https://{}.slack.com", "url": "https://{}.slack.com",
"errorType": "status_code", "errorType": "status_code",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"Trip": { "Trip": {
"url": "https://www.trip.skyscanner.com/user/{}", "url": "https://www.trip.skyscanner.com/user/{}",
@ -341,7 +341,7 @@
"url": "https://{}.wordpress.com", "url": "https://{}.wordpress.com",
"errorType": "response_url", "errorType": "response_url",
"errorUrl": "wordpress.com/typo/?subdomain=", "errorUrl": "wordpress.com/typo/?subdomain=",
"noPeriod": "True" "regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$"
}, },
"Unsplash": { "Unsplash": {
"url": "https://unsplash.com/@{}", "url": "https://unsplash.com/@{}",

@ -2,6 +2,7 @@ import requests
import json import json
import os import os
import sys import sys
import re
import argparse import argparse
DEBUG = False DEBUG = False
@ -67,12 +68,17 @@ def sherlock(username):
for social_network in data: for social_network in data:
url = data.get(social_network).get("url").format(username) url = data.get(social_network).get("url").format(username)
error_type = data.get(social_network).get("errorType") error_type = data.get(social_network).get("errorType")
cant_have_period = data.get(social_network).get("noPeriod") regex_check = data.get(social_network).get("regexCheck")
if ("." in username) and (cant_have_period == "True"): if regex_check is None:
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m User Name Not Allowed!".format(social_network)) #Use default regular expression check for user names.
regex_check = "^[a-zA-Z][a-zA-Z0-9._-]*$"
if re.search(regex_check, username) is None:
#No need to do the check at the site: this user name is not allowed.
print("\033[37;1m[\033[91;1m-\033[37;1m]\033[92;1m {}:\033[93;1m Illegal User Name Format For This Site!".format(social_network))
continue continue
r, error_type = make_request(url=url, headers=headers, error_type=error_type, social_network=social_network) r, error_type = make_request(url=url, headers=headers, error_type=error_type, social_network=social_network)
if error_type == "message": if error_type == "message":

Loading…
Cancel
Save