This file is indexed.

/usr/lib/ruby/vendor_ruby/wikicloth/extensions/lua.rb is in ruby-wikicloth 0.8.1+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
begin
  require 'rubyluabridge'
  DISABLE_LUA = false
rescue LoadError
  DISABLE_LUA = true
end

module WikiCloth
  class LuaExtension < Extension

    # <lua var1="value" ...>lua code</lua>
    #
    element 'lua', :skip_html => true, :run_globals => false do |buffer|
      init_lua
      unless @options[:disable_lua]
        begin
          arglist = ''
          buffer.element_attributes.each do |key,value|
            arglist += "#{key} = '#{value.addslashes}';"
          end
          lua_eval("#{arglist}\n#{buffer.element_content}").to_s
        rescue => err
          "<span class=\"error\">#{err.message}</span>"
        end
      else
        "<!-- #{I18n.t('lua disabled')} -->"
      end
    end

    # {{#luaexpr:lua expression}}
    #
    function '#luaexpr' do |params|
      init_lua
      unless @options[:disable_lua]
        begin
          lua_eval("print(#{params.first})").to_s
        rescue => err
          "<span class=\"error\">#{err.message}</span>"
        end
      else
        "<!-- #{I18n.t('lua disabled')} -->"
      end
    end

    protected
    def init_lua
      if @options[:disable_lua].nil?
        begin
          @options[:disable_lua] ||= DISABLE_LUA
          lua_max_lines = @options[:lua_max_lines] || 1000000
          lua_max_calls = @options[:lua_max_calls] || 20000

          unless @options[:disable_lua]
            @options[:luabridge] = Lua::State.new
            @options[:luabridge].eval(File.read(File.join(File.expand_path(File.dirname(__FILE__)), "lua", "luawrapper.lua")))
            @options[:luabridge].eval("wrap = make_wrapper(#{lua_max_lines},#{lua_max_calls})")
          end
        rescue
          @options[:disable_lua] = true
        end
      end
    end

    def lua_eval(code)
      @options[:luabridge]['chunkstr'] = code
      @options[:luabridge].eval("res, err = wrap(chunkstr, env, hook)")
      unless @options[:luabridge]['err'].nil?
        if @options[:luabridge]['err'] =~ /LOC_LIMIT/
          "<span class=\"error\">#{I18n.t("max lines of code")}</span>"
        elsif @options[:luabridge]['err'] =~ /RECURSION_LIMIT/
          "<span class=\"error\">#{I18n.t("recursion limit reached")}</span>"
        else
          "<span class=\"error\">#{@options[:luabridge]['err']}</span>"
        end
        nil
      else
        @options[:luabridge]['res']
      end
    end

  end
end