summaryrefslogtreecommitdiffhomepage
path: root/images/jekyll/checks.rb
diff options
context:
space:
mode:
authorIan Lewis <ianlewis@google.com>2020-07-17 18:26:08 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-17 18:27:41 -0700
commitfeb1d3d5a7d9c26ab1533b350a9d6088148641aa (patch)
tree13ef1f368b665116bedc90ddd0c96f43d5448498 /images/jekyll/checks.rb
parent5593320bee3e4ab215f501a723ef3ea92b20cf85 (diff)
Clean up html on the website.
- Fixes some html validation issues. - Fixes links on security basics blog post. - Adds rel=noopener to links with target=_blank and adds a check to htmlproofer. - Add favicon check to htmlproofer. Fixes #3286 Fixes #3284 PiperOrigin-RevId: 321892602
Diffstat (limited to 'images/jekyll/checks.rb')
-rw-r--r--images/jekyll/checks.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/images/jekyll/checks.rb b/images/jekyll/checks.rb
new file mode 100644
index 000000000..fc7e6b5a8
--- /dev/null
+++ b/images/jekyll/checks.rb
@@ -0,0 +1,36 @@
+#!/usr/local/bin/ruby
+#
+# HTMLProofer checks for the gVisor website.
+#
+require 'html-proofer'
+
+# NoOpenerCheck checks to make sure links with target=_blank include the
+# rel=noopener attribute.
+class NoOpenerCheck < ::HTMLProofer::Check
+ def run
+ @html.css('a').each do |node|
+ link = create_element(node)
+ line = node.line
+
+ rel = link.respond_to?(:rel) ? link.rel.split(' ') : []
+
+ if link.respond_to?(:target) && link.target == "_blank" && !rel.include?("noopener")
+ return add_issue("You should set rel=noopener for links with target=_blank", line: line)
+ end
+ end
+ end
+end
+
+def main()
+ options = {
+ :check_html => true,
+ :check_favicon => true,
+ :disable_external => true,
+ }
+
+ HTMLProofer.check_directories(ARGV, options).run
+end
+
+if __FILE__ == $0
+ main
+end