trathborne/Dancer-Plugin-EscapeHTML — comment on commit 262b9725bd50ebc9c199b8fe9003baaed359533b
File: lib/Dancer/Plugin/EscapeHTML.pm line 135
By trathborne:

Hi David,

On Thu, Nov 03, 2011 at 01:58:19PM -0700, David Precious wrote:
> I'm not quite sure, but I think I'd rather use
> Scalar::Util::reftype() here (e.g. `Scalar::Util::reftype($in) eq
> 'ARRAY'`) as I think it's marginally cleaner.

Definitely cleaner. I like to keep dependencies down so I don't
usually look for a module when I can do something reasonably
concisely. Scalar::Util looks good.

> I'll merge the PR then make that little tweak. Other than that,
> very sensible change, thanks!

On Thu, Nov 03, 2011 at 01:55:23PM -0700, David Precious wrote:
> This is a very good point - blindly going around and escaping the
> internal values of an object probably isn't desired behaviour :)

Right, what if I accidentally pass my DBI::db handle? :)

On Thu, Nov 03, 2011 at 02:57:02PM -0700, David Precious wrote:
> Right - merged in, tweaked slightly, tests added, and version 0.20
> pushed out to CPAN - thanks!

Great. I've merged from upstream and it's working great here.
Until I pass the wrong object, of course.

> Will give some thought to the option of providing patterns to match
> objects that should be messed about with.

I think a simple regex match on the classname would do it -- most data
objects are in some class hierarchy, no? e.g. MyApp::MyDbObjects

Another option would be:
$seen{scalar $in} = 1;
+$in = $in->profane if blessed($in) and $in->can('profane');
where 'profane' returns an inert, unblessed copy of the object.
Then only classes which implement this method would be traversed.
For anonymous hash objects, that's as simple as:
sub profane {{%{shift}}}

Any other ideas?

Cheers,

Tom

--
-- Tom Rathborne ------------------------------- World-renowned Human Shaman --
Growth for the sake of growth is the ideology of a cancer cell.
-- Edward Abbey