Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
I consider bbcoder to be stable so you won't see many updates to it in the future. It is perfectly fine to use in production. The gem itself is pretty simple so it should work across the board with newer frameworks etc. If you find any issues or think it needs a feature please submit an issue.
Non-regex based (except for the split)
Handles deep nesting of tags
Generates good html even from bad input
Easy configuration to add new tags
Tags supported by default:
p, b, i, u, s, del, ins, ol, ul, li, dl, dt, dd, quote, code, spoiler, url, img, youtube, sub, sup
BBCoder.new(h(text)).to_html
# or
h("[p]my string[/p]").bbcode_to_html
# h() is a Rails helper function, you may use CGI.escapeHTML instead
See configuration section below on adding new parseable tags
gem install bbcoder
bbcoder is not meant to handle smileys, autolinking or xss attacks. There are other libraries to help do this for us. I also do not consider these elements part of bbcode itself (even though there is no standard) so bbcoder will not provide support for them except in this README to give examples on how to combine them together.
Rails 2.x has a helper auto_link by default that can do this for you. For Rails 3.x you can install the rails_autolink gem.
At the moment I use a jquery library to display smileys after the page has loaded. The library I use https://github.com/JangoSteve/jQuery-CSSEmoticons however it would be nice to see a gem that can parse smileys out of text into appropriate html elements with specific tags. CSS3 font-face anyone?
Please make sure you escaped or sanitized all HTML in the string before passing it to bbcoder!
bbcoder will now do a whitelist check against img tags and url tags by default and only allow http/https links. You can override this by putting in your own configuration if you wish. If you find any other flaws or holes please report so we can fix. bbcoder will not sanitize the rest of your input, it will only attempt to whitelist the actual html elements it will generate.
When typing into a textarea a user will use newlines to indicate space between lines. This is not translated properly into br tags. I do not consider this a function for bbcoder either atm, however I do use it in combination with XSS/Sanitize above:
def bbcode(text)
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "<br />").html_safe
end
BBCoder.configure do
tag :b, :as => :strong
tag :sub, :singular => true do
%(<sub>#{singular? ? meta : content}</sub>)
end
tag :sup, :singular => true do
%(<sup>#{singular? ? meta : content}</sup>)
end
tag :ul
tag :ol
tag :li, :parents => [:ol, :ul]
tag :url, :match_link => /^https?:\/\// do
if meta.nil? || meta.empty?
%(<a href="#{content}">#{content}</a>)
else
%(<a href="#{meta}">#{content}</a>)
end
end
tag :img, :match => /^https?:\/\/.*(png|bmp|jpe?g|gif)$/, :singular => true do
%(<a href="#{singular? ? meta : content}"><img src="#{singular? ? meta : content}" /></a>)
end
tag :code do
<<-EOS
<div class="bbcode-code #{meta}">
<pre>#{content}</pre>
</div>
EOS
end
remove :spoiler # Removes [spoiler]
end
Options for #tag
When you pass a block to #tag it is expecting you to return a string. You have two variables available to your block:
You can remove all configured tags by calling BBCoder.configuration.clear
.
Original author: John "asceth" Long
FAQs
Unknown package
We found that bbcoder 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.