Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NameError: uninitialized constant Sanitize::Error in transformer with syntax error #15

Closed
ahx opened this issue Jan 20, 2010 · 2 comments
Labels

Comments

@ahx
Copy link

ahx commented Jan 20, 2010

When i use plain Sanitize and provide a bad transformer, i get the above exception. Maybe you could raise the standard ArgumentError or the like.

Reproduce:
Sanitize.clean("<script>fail();</script>", :transformers => lambda {|env| :badtransformer })

@rgrove
Copy link
Owner

rgrove commented Jan 20, 2010

From Sanitize's point of view, the transformer argument is a lambda and has a call() method, so it's a valid argument. An ArgumentError in this case would be misleading.

The problem is that the lambda contains a syntax error, and the resulting exception is unintuitive and broken, so that's the part that needs fixing. We'll need to make sure Sanitize bubbles up meaningful exceptions when there are problems inside transformers.

@rgrove
Copy link
Owner

rgrove commented Jan 23, 2010

Returning anything other than a Hash or nil from a transformer will now raise a meaningful Sanitize::Error exception rather than an unintended NameError. Closed by 0a8e5f2

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants