Comments (3)
I'm no regExp expert I was just going by this for rough equiv of look behind https://stackoverflow.com/a/74994273/738957
This was crashing our entire app, if this fix has a side effect on some anchorme links its preferable over an entire crash.
However if there is a better fix would be good to know.
from anchorme.js.
Please check the latest version 3.0.7
from anchorme.js.
Current fix gives wrong capture group results, as there are more capture groups in the lookaround-supporting regex than there are in the compat-mode regex:
const OriginalRegExp = globalThis.RegExp;
class SafariRegExp extends OriginalRegExp {
constructor(pattern, flags) {
super(pattern, flags)
if (String(pattern).includes('(?<=')) {
throw new SyntaxError('idk what (?<= even means')
}
}
}
globalThis.RegExp = SafariRegExp
const anchorme = (await import('https://esm.sh/v135/[email protected]')).default
console.info(
anchorme.list(
`https://example.xyz example.com [email protected] file:///filename.txt 192.168.1.1`,
false,
)
)
// expected:
[
{ start: 0, end: 19, string: 'https://example.xyz', isURL: true, protocol: 'https://', /* ... */ },
{ start: 20, end: 31, string: 'example.com', isURL: true, protocol: undefined, /* ... */ },
{ start: 32, end: 46, string: '[email protected]', isEmail: true, local: 'user', /* ... */ },
{ start: 47, end: 67, string: 'file:///filename.txt', isFile: true, protocol: 'file:///', /* ... */ },
{ start: 68, end: 79, string: '192.168.1.1', isURL: true, protocol: undefined, /* ... */ },
]
// actual:
[
{ start: 0, end: 19, string: 'https://example.xyz', reason: 'unknown' },
{ start: 20, end: 31, string: 'example.com', reason: 'unknown' },
{ start: 32, end: 46, string: '[email protected]', reason: 'unknown' },
{ start: 47, end: 67, string: 'file:///filename.txt', isURL: true, protocol: undefined, /* ... */ },
{ start: 68, end: 79, string: '192.168.1.1', reason: 'unknown' },
]
I'll have a PR up with a fix shortly â I think with the fix, reason: "unknown"
can also be removed entirely as it should never occur.
from anchorme.js.
Related Issues (20)
- Extensions prevents from parsing some urls and emails
- Malformed links if they contain german umlaute
- `https://âĶa.com` is detected as a url, but it's invalid to URL
- security contact HOT 1
- Mutation XSS + general sanitization HOT 3
- anchorme fails to curretly hyperlink URLs having < and > in them HOT 1
- anchorme is not a function HOT 4
- Infinite Recursion browser tab crashes HOT 3
- Urls with localhost:port number will not work HOT 1
- link strings surrounded by underscore don't always work HOT 1
- URLs ending with hyphen exclude hyphen HOT 1
- The content came with Img tag and this library wrap img src link anchor tag HOT 1
- Imcompatibility with older iOS systems HOT 5
- Reference to mocha in index.d.ts HOT 2
- Cannot import correctly under TypeScript Node 16 module resolution HOT 2
- Query string on url is not supported HOT 1
- Invalid regular expression on Safari iOS < 16.4 HOT 6
- Not recognizing query params when using: `...)?...`
- attribute position
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ððð
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google âĪïļ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anchorme.js.