Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
replaced url regex to avoid catastrophic backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jul 6, 2021
1 parent 0128609 commit a050513
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 560 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tabby-clickable-links",
"version": "4.0.0",
"version": "4.1.0",
"description": "Makes URLs, IPs and file paths clickable in Tabby",
"keywords": [
"tabby-plugin"
Expand All @@ -24,22 +24,22 @@
"@angular/forms": "^9.1.9",
"@angular/platform-browser": "^9.1.9",
"@ng-bootstrap/ng-bootstrap": "^6.1.0",
"@types/node": "^16.0.0",
"@types/webpack-env": "^1.16.0",
"awesome-typescript-loader": "^5.2.1",
"electron": "^12.0.0-beta.22",
"apply-loader": "^2.0.0",
"ng2-dnd": "5.0.2",
"ngx-toastr": "^8.8.0",
"pug": "^3.0.2",
"pug-loader": "^2.4.0",
"rxjs": "^6.5.5",
"tabby-core": "^1.0.140",
"tabby-settings": "^1.0.140",
"tabby-terminal": "^1.0.140",
"ts-loader": "^5.2.1",
"typescript": "^3.1.3",
"untildify": "^3.0.2",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2",
"apply-loader": "^2.0.0",
"pug-loader": "^2.4.0",
"untildify": "^3.0.2",
"winston": "^3.3.3"
},
"repository": "eugeny/tabby-clickable-links"
Expand Down
5 changes: 2 additions & 3 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import { LinkHandler } from './api'

@Injectable()
export class URLHandler extends LinkHandler {
// From https://daringfireball.net/2010/07/improved_regex_for_matching_urls
// See : https://stackoverflow.com/questions/6927719/url-regex-does-not-work-in-javascript
regex = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))/
// From https://urlregex.com/
regex = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/

priority = 5

Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const webpack = require('webpack')
module.exports = {
target: 'node',
entry: 'src/index.ts',
mode: 'development',
mode: 'production',
context: __dirname,
output: {
path: path.resolve(__dirname, 'dist'),
Expand All @@ -21,9 +21,9 @@ module.exports = {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
loader: 'ts-loader',
query: {
configFileName: path.resolve(__dirname, 'tsconfig.json'),
configFile: path.resolve(__dirname, 'tsconfig.json'),
}
},
{ test: /\.pug$/, use: ['apply-loader', 'pug-loader'] },
Expand Down
Loading

0 comments on commit a050513

Please sign in to comment.