quickdraw/compilation_equivalence_cases/reference_prefixes.rb
Lines
0%0 of 26 covered
Branches
—0 of 0 covered
Methods
0%0 of 3 covered
- Not run
- 3-5713-141620-2326-2730-4143
- Never called
| 1 | # frozen_string_literal: true | |
| 2 | ||
| 3 | 0 | module EquivalenceCases |
| 4 | 0 | module ReferencePrefixes |
| 5 | 0 | class ReferencePrefixes < Phlex::HTML |
| 6 | VALUES = [ | |
| 7 | 0 | "1", |
| 8 | "javascript:alert(1)", | |
| 9 | "javascript:x", | |
| 10 | %(say "hi"), | |
| 11 | "caféé", | |
| 12 | "x:", | |
| 13 | 0 | (+"&\xFF").force_encoding(Encoding::UTF_8), |
| 14 | 0 | (+":j\xFF").force_encoding(Encoding::UTF_8), |
| 15 | "\xFFé".b, | |
| 16 | 0 | (+"\xE9é").force_encoding(Encoding::ISO_8859_1), |
| 17 | "x".encode(Encoding::UTF_16LE), | |
| 18 | ].freeze | |
| 19 | ||
| 20 | 0 | def self.equivalence_scenarios |
| 21 | 0 | VALUES.each_with_index.to_h do |value, index| |
| 22 | 0 | ["value #{index}", -> (klass) { klass.new(value).call }] |
| 23 | 0 | end.merge("fragment" => -> (klass) { klass.new("x").call(fragments: [:f]) }) |
| 24 | end | |
| 25 | ||
| 26 | 0 | def initialize(value) |
| 27 | 0 | @value = value |
| 28 | end | |
| 29 | ||
| 30 | 0 | def view_template |
| 31 | 0 | a(href: "/posts/#{@value}") { "post" } |
| 32 | 0 | a(href: "mailto:#{@value}", class: "m") |
| 33 | 0 | img(src: "https://example.com/#{@value}.png") |
| 34 | 0 | a(href: "java#{@value}") |
| 35 | 0 | a(href: "javascript:#{@value}") |
| 36 | 0 | a(href: "/#{@value}") |
| 37 | 0 | a(href: "JaVascript:#{@value}") |
| 38 | 0 | a(href: " Java Script:#{@value}") |
| 39 | 0 | a(href: %(/q"#{@value})) |
| 40 | 0 | a(href: "\xC3#{@value}") |
| 41 | 0 | fragment(:f) { a(href: "/f/#{@value}") } |
| 42 | rescue => error | |
| 43 | 0 | plain "rescued #{error.class}" |
| 44 | end | |
| 45 | end | |
| 46 | end | |
| 47 | end |