
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Replace URLs in text with HTML links, ignore the URLs within a href/pre tag.
Auto-link is an npm package that replaces URLs in text with HTML links, ignore the URLs within a href/pre tag.
npm install --save auto-link
var autoLink = require('auto-link');
Using the link() method:
var html = autoLink.link(text[, options]);
var html = autoLink.link('<p>Welcom to www.google.com</p>');
//<p>Welcom to <a href="http://www.google.com">www.google.com</a></p>
These are specified by providing an Object as the second parameter to autoLink.link().
target
: String or Booleantarget
option is a String value. false
means that do not add target attribuite.false
.autoLink.link('<p>Welcom to www.google.com</p>', {
target: '_blank'
});
//<p>Welcom to <a href="http://www.google.com" target="_blank">www.google.com</a></p>
attrs
: ObjectautoLink.link('<p>Welcom to www.google.com</p>', {
attrs: {
class: 'mylink',
name: 'mylink1',
id: 'mylink2'
}
});
//<p>Welcom to <a href="http://www.google.com" class="mylink" name="mylink1" id="mylink2">www.google.com</a></p>
ignore.tags
: Array[String]<a href="http://www.google.com">www.google.com</a>
should NOT be replaced to <a href="<a href="http://www.google.com">http://www.google.com</a>"><a href="http://www.google.com">www.google.com</a></a>
. So the The URLs text within ignore.tags
won't be replaced.['a', 'pre', 'code', 'textarea']
.autoLink.link('<p>Welcom to <a href="http://www.google.com">www.google.com</a></p>');
//<p>Welcom to <a href="http://www.google.com">www.google.com</a></p>
autoLink.link('<p>Welcom to www.google.com</p>, <span>www.stackoverflow.com</span> and <pre>www.github.com</pre>', {
ignore: {
tags: ['p', 'span']
}
});
//<p>Welcom to www.google.com</p>, <span>www.stackoverflow.com</span> and <pre><a href="http://www.github.com">www.github.com</a></pre>
ignore.classes
: Array[String]ignore.tags
, but it's for CSS classes.['hljs']
.e.g.
autoLink.link('<p class="hljs">Welcom to www.google.com <span class="myclass">and www.github.com</span></p>', {
ignore: {
classes: ['myclass']
}
});
//<p class="hljs">Welcom to <a href="http://www.google.com">www.google.com</a> <span class="myclass">and www.github.com</span></p>
ignore.fn
: Functionignore.fn
is used to filter the elements which you want to ignore. The function has a JSDOM element as it's parameter, it should retrun a boolean value to specify the element ignores or not.ignore.fn
option, the ignore.tags
and ignore.classes
options will be invalidated.autoLink.link('<p id="hljs">Welcom to www.google.com <span id="myid1">and www.github.com</span></p>', {
ignore: {
fn: function(ele) {
return ele.attr('id') && ele.attr('id').indexOf('myid') > -1;
}
}
});
//<p id="hljs">Welcom to <a href="http://www.google.com">www.google.com</a> <span id="myid1">and www.github.com</span></p>
$ npm install -g mocha
npm test
FAQs
Replace URLs in text with HTML links, ignore the URLs within a href/pre tag.
The npm package auto-link receives a total of 9 weekly downloads. As such, auto-link popularity was classified as not popular.
We found that auto-link demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.