VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/lib/gems/2.5.0/gems/escape_utils-1.0.1/test/query/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/lib/gems/2.5.0/gems/escape_utils-1.0.1/test/query/unescape_test.rb
require File.expand_path("../../helper", __FILE__)

class QueryUnescapeTest < Minitest::Test
  def test_basic_url
    assert_equal "http://www.homerun.com/", EscapeUtils.unescape_url("http%3A%2F%2Fwww.homerun.com%2F")
  end

  def test_url_containing_tags
    assert_equal "fo<o>bar", EscapeUtils.unescape_url("fo%3Co%3Ebar")
  end

  def test_url_containing_spaces
    assert_equal "a space", EscapeUtils.unescape_url("a+space")
    assert_equal "a   sp ace ", EscapeUtils.unescape_url("a+++sp+ace+")
  end

  def test_url_containing_mixed_characters
    assert_equal "q1!2\"'w$5&7/z8)?\\", EscapeUtils.unescape_url("q1%212%22%27w%245%267%2Fz8%29%3F%5C")
  end

  def test_url_containing_multibyte_characters
    matz_name = "\xE3\x81\xBE\xE3\x81\xA4\xE3\x82\x82\xE3\x81\xA8" # Matsumoto
    matz_name.force_encoding('UTF-8') if matz_name.respond_to?(:force_encoding)
    assert_equal matz_name, EscapeUtils.unescape_url('%E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8')
    matz_name_sep = "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8" # Matsu moto
    matz_name_sep.force_encoding('UTF-8') if matz_name_sep.respond_to?(:force_encoding)
    assert_equal matz_name_sep, EscapeUtils.unescape_url('%E3%81%BE%E3%81%A4+%E3%82%82%E3%81%A8')
  end

  if RUBY_VERSION =~ /^1.9/
    def test_input_must_be_valid_utf8_or_ascii
      escaped = EscapeUtils.unescape_url("a+space")

      escaped.force_encoding 'ISO-8859-1'
      assert_raises Encoding::CompatibilityError do
        EscapeUtils.unescape_url(escaped)
      end

      escaped.force_encoding 'UTF-8'
      begin
        EscapeUtils.unescape_url(escaped)
      rescue Encoding::CompatibilityError => e
        assert_nil e, "#{e.class.name} raised, expected not to"
      end
    end

    def test_return_value_is_tagged_as_utf8
      escaped = EscapeUtils.escape_url("a space")
      assert_equal Encoding.find('UTF-8'), EscapeUtils.unescape_url(escaped).encoding
    end
  end
end

VaKeR 2022