Re: auto-upgrading strings to utf8



On man, 2005-06-06 at 03:09 +0200, A. Pagaltzis wrote:
* muppet <scott asofyet org> [2005-06-05 22:05]:
I can think of three fixes for this:

b) turn off auto-upgrading, and push the burden of ensuring
utf8-ness of text onto perl developers. this risks breaking
lots of existing code.

That is so wrong. In the default case, auto-upgrading is the
right thing to do. We know there are so edge cases which require
special treatment. Making the default case require extra work so
that the edge cases do not is just ass backwards and would
introduce subtle bugs where people forget these things.

Obviously I agree here. Gtk2 is doing the right thing here.
Unfortunately, lots of other perl modules do not.

Think of SQL injection vulnerabilities; people constantly forget
where they have to quote things and where not. Of course, for SQL
queries this is difficult to solve; but why introduce the same
kind of subtlety into an API where it’s simple to avoid?
 
a) if it's the case that a G_TYPE_STRING really is supposed to
be utf8, then GstFileSrcElement is broken, and should do
something like g_filename_from_utf8() on the string it gets
from the location property. the bindings would have to do
nothing. this risks breaking C programs, but GStreamer is still
at a nonstable version...

Unless there’s an actual, non-obvious, but compelling reason for
GStreamer to do otherwise, that’s clearly the correct solution.

Unfortunately there is a reason. Filenames really should be treated as
opaque data. The reason for this is that there is no way to be sure of
the encoding of filenames (it might not even be consistent). After all
locales can be set per user. To make matters worse not all scripts can
be represented in unicode.

But we all know that filenames are not treated as opaque. If nothing
else they are concatenated with other bit of the path. Which in perl may
lead to an upgrade.

c) add infrastructure to the bindings to allow per-property
overrides for marshaling. this would slow down the general case
and take up even more memory (another hash table and lookup per
property), but would allow problems like this (and
G_TYPE_POINTER properties) to be fixed.

That would be the right thing to do if GStreamer does have reason
for doing things the way it does (rather than it being a simple
oversight).

Would there be a way to do this specifically within the GStreamer
bindings (a special overridden version of Glib::Object::set(),
say) rather than penalizing all of Gtk2-Perl for it?

After a brief discussion on IRC last night I think Torsten will see if
this solution flies. Ie a ->set(...) which splits out location and sets
it without going through the standard set.

./borup




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]