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.
RRTF enables programatic creation of Rich Text Format (RTF) documents in Ruby, focusing on simplifying RTF document assembly and generating clean RTF source code. This gem is founded on the ifad-rtf gem, but has simpler syntax and supports more RTF constructs.
The gem was created with reference to the Microsoft Office RTF Specification (v1.9.1). The syntax for custom shapes was determined by reverse engineering the RTF output from Word 2016 and reference to Microsoft's Binary Format Specification (pp. 32-33).
Add this line to your application's Gemfile:
gem 'rrtf'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rrtf
require 'rrtf'
# Construct an object representing the RTF document
rtf = RRTF::Document.new
# ...
# Call methods on `rtf` to generate content
# ...
# Convert document into RTF string
rtf.to_rtf
Plain paragraph
rtf.paragraph << \
"Should you ever find yourself on a spacefaring vessel "\
"wearing RED shirt, take heed and be on guard, for danger "\
"is immanent and you are likely expendable among the crew."
Paragraph with inline styling
rtf.paragraph(
"justification" => "RIGHT",
"foreground_color" => '#ff0000',
"font" => "ROMAN:Times"
) << \
"Should you ever find yourself on a spacefaring vessel "\
"wearing RED shirt, take heed and be on guard, for danger "\
"is immanent and you are likely expendable among the crew."
Paragraph with inline character styling
rtf.paragraph do |p|
p << "Should you ever find yourself on a spacefaring vessel wearing a "
p.apply(
"foreground_color" => '#ff0000',
"underline_color" => '#ff0000',
"italic" => true,
"bold" => true,
"underline" => "SINGLE"
) << "red"
p << " shirt, take heed and be on guard, for danger "
p << "is immanent and you are likely expendable among the crew."
end
rtf.paragraph do |p|
p << "Should you ever find yourself on a spacefaring vessel wearing a "
p.apply(
"foreground_color" => '#ff0000',
"underline_color" => '#ff0000',
"italic" => true,
"bold" => true,
"underline" => "SINGLE"
) do |emphasis|
emphasis.link(
"https://en.wikipedia.org/wiki/Redshirt_(character)", "red shirt")
end
p << ", take heed and be on guard, for danger "
p << "is immanent and you are likely expendable among the crew."
end
rtf.list do |l|
l.item do |li|
li << "Never venture into an ominous setting."
end
l.item do |li|
li << "Never attempt to disable an unknown entity. "
li << "Get away quickly."
end
l.item do |li|
li << "Never stand guard alone. Make certain at least three "
li << "other redshirts are present."
end
end
rtf.image(DIR+'/resources/images/redshirt.png',
"width" => "2in", # can also set "height"
"sizing_mode" => "FIX_ASPECT_RATIO", # can also be "ABSOLUTE"
"border" => {
"sides" => "ALL",
"color" => '#ff0000',
"line_type" => "DOT",
"width" => "5pt",
"spacing" => "12pt"
}
)
Basic shapes
rtf.geometry(
"type" => "RECTANGLE",
"fill_color" => '#cccccc',
"top" => 0,
"left" => 0,
"width" => "2in",
"height" => "2in",
"horizontal_reference" => "PAGE",
"vertical_reference" => "PAGE"
)
Text boxes
rtf.geometry(
"type" => "TEXT_BOX",
"line_color" => '#000000',
"line_width" => '3pt',
"top" => "5in",
"left" => "2.5in",
"width" => "3in",
"height" => "3in",
"horizontal_reference" => "PAGE",
"vertical_reference" => "PAGE"
) do |box|
box.paragraph do |p|
p << "Should you ever find yourself on a spacefaring vessel wearing a "
p << "RED"
p << " shirt, take heed and be on guard, for danger "
p << "is immanent and you are likely expendable among the crew."
end
end
Custom shapes
rtf.geometry(
"type" => "CUSTOM",
"top" => 0,
"left" => "4in",
"width" => "3in",
"height" => "3in",
"path" => [
# points are relative to the upper left corner of the shape as
# determined by "top"/"left"/"bottom"/"right"/"width"/"height"
["START_AT", [0,0] ],
["LINE_TO", ['2in', 0] ],
["CUBIC_BEZIER_TO", ['3in', 0], ['3in', '1.5in'], ['3in', '3in'] ],
["LINE_TO", [0, 0] ],
["CLOSE_PATH" ],
["END" ]
],
"fill_color" => '#00cc00',
"line_color" => '#000099'
)
raw_styles = JSON.parse File.read(DIR+'/resources/json/redshirt_styles.json')
rtf = RRTF::Document.new("stylesheet" => raw_styles)
styles = rtf.stylesheet.styles
rtf.paragraph(styles['TITLE']) << "Redshirt Pocket Guide"
rtf.paragraph(styles['SUBTITLE']) do |p|
p << "3"
p.apply("superscript" => true) << "rd"
p << " Edition"
end
rtf.paragraph << "Redshirt Pocket Guide"
# start a new section with the prescribed styling
rtf.section("columns" => 2)
rtf.paragraph << "Section Text"
rtf.paragraph("tabs" => {
"leader" => "DOT",
"type" => "FLUSH_RIGHT",
"position" => "2in"
}) do |p|
p << "Engineers"
p.tab
p << "10"
p.line_break
p << "Redshirts"
p.tab
p << "100"
end
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/whileman133/rrtf.
Just like ifad-rtf, this gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that rrtf 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.