Skip to content

Commit

Permalink
[.] regex added, ranking regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
atakanaydinbas committed Jan 1, 2024
1 parent d8f6185 commit 4bd837f
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions defang.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,32 @@ func DefangAll(input string) string {

var DefangPatterns = []map[string]string{
{
"find": `(?:\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b[a-zA-Z0-9-]+\.[a-zA-Z]{2,}\b)`,
"change": ".",
"replace": "[.]",
"find": `(https?://\S+)`,
"change": "https:",
"replace": "hXXps:",
},

{
"find": `^(http:\/\/)`,
"change": "http:",
"replace": "hXXp:",
},

{
"find": `^(https:\/\/)`,
"change": "https:",
"replace": "hXXps:",
},

{
"find": `([a-zA-Z0-9_.+-]+)@([a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)`,
"change": "@",
"replace": "[AT]",
},
{
"find": `([a-zA-Z0-9_.+-]+)\.([a-zA-Z]{2,})`,
"find": `(\d+\.\d+\.\d+\.\d+)([^0-9])`,
"change": ".",
"replace": "[.]",
},
{
"find": `(\.)([a-zA-Z]{2,})`,
"find": `\d+\.\d+\.\d+\.(\d+)`,
"change": ".",
"replace": "[.]",
},
{
"find": `([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)\.([a-zA-Z]{2,})`,
"find": `[^.]\.([a-zA-Z0-9])`,
"change": ".",
"replace": "[.]",
},
Expand Down

0 comments on commit 4bd837f

Please sign in to comment.