Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sanitizing data causes "undefined method `strip' for #<Array..." #325

Closed
epipheus opened this issue Apr 11, 2019 · 1 comment
Closed

sanitizing data causes "undefined method `strip' for #<Array..." #325

epipheus opened this issue Apr 11, 2019 · 1 comment
Assignees
Labels

Comments

@epipheus
Copy link

epipheus commented Apr 11, 2019

I'm getting an error in the browser when ajax-datatables-rails calls sanitize(data) here

When I track it down it doesn't like this line in Nokogiri (parent of Loofah)

          # This is a horrible hack, but I don't care
          if tags.strip =~ /^<body/i
            path = "/html/body"
          else
            path = "/html/body/node()"
          end
epipheus added a commit to epipheus/ajax-datatables-rails that referenced this issue Apr 11, 2019
…fferent things. Because datatables inherit from AjaxDatatablesRails::ActiveRecord which inherits from AjaxDatatablesRails::Base for some odd reason sanitize binds to ActionView's sanitize method which eventually gets to Loofah and Nokogiri which doesn't handle arrays and throws the error I reported in jbox-web#325 surprisingly even when you call self.sanitize it does not call the method in the same namespace and file!! because technically the sanitize function that we want is AjaxDatatablesRails::Base's function, to disabiguate we could either rename the function (and because I don't know what else calls it that seemed like a bad idea), or we could help disambiguate by being explicit about which super's method to call.  The only way I saw to do this is to call it like this: AjaxDatatablesRails::Base.instance_method(:sanitize).bind(self).call(data).  That may make for unreadable code to some, we could always define another method that then calls AjaxDatatablesRails::Base.instance_method(:sanitize).bind(self).call(data).  Or if you have another way to fix, have at it.  But this breaks in Ruby 2.4.0 and rails 5.2.3 for me without this change.
@n-rodriguez
Copy link
Member

Closing the issue since you found the bug ;) thank you 👍

@n-rodriguez n-rodriguez self-assigned this Apr 17, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants