PDA

View Full Version : caveat: web INPUT naming & pref namespace collisions



peterw
2007-11-28, 20:51
Gordon Harris helped me find an odd problem with one of my 7.x alpha releases.

7.x's use of namespaces for preferences led me to believe that I could use practically any pref names I wanted, for instance "port" under plugins.BottleRocket shouldn't conflict with "port" under plugins.MoodLogic or whatever.

But the web settings pages do *not* use fully qualified names in their HTML code. The HTML for plugins.BottleRocket.port looks like

<label for="port">[% "SETUP_PLUGIN-BOTTLEROCKET-BR-PORT_DESC" | string %]</label></td>
<br><input type="text" class="stdedit" name="port" id="port" value="[% prefs.port %]" />

And that works fine for "port". It did not work well for "command".

Why? There are some special names that SC7 (and SS) use for HTTP name=value data like "p0", "p1", and ... "command" and "subcommand".

Install BottleRocket on Linux and it would default to a "command" value like "/usr/share/SqueezeCenter/Plugins/BottleRocket/bin/br". The global settings page would pick that up & display it in the text input. But if a user tried to Save Settings, SC7 would see an HTTP request with command=/usr/share/SqueezeCenter/Plugins/BottleRocket/bin/br and would try (and fail) to execute the Slim/CLI command "/usr/share/SqueezeCenter/Plugins/BottleRocket/bin/br", resulting in a wacky "HTTP Status 000 Unknown" error and SC7 neither responding to the HTTP request nor saving the user's settings.

The workaround: don't use any preference name that matches any of the special argument names in Slim::Web::HTTP if the user should be able to change that preference via the web UI.

I think it'd probably be good if the normal model were to prepend the namespace to the HTML attributes, e.g.

<label for="plugins.BottleRocket.port">[% "SETUP_PLUGIN-BOTTLEROCKET-BR-PORT_DESC" | string %]</label></td>
<br><input type="text" class="stdedit" name="plugins.BottleRocket.port" id="plugins.BottleRocket.port" value="[% prefs.port %]" />

-Peter

kdf
2007-12-13, 09:40
On 28-Nov-07, at 7:51 PM, peterw wrote:
>
> I think it'd probably be good if the normal model were to prepend the
> namespace to the HTML attributes, e.g.

Please file a bug report. This is probably not something that we can
get to in time for 7.0 but worth considering in a future cleanup.
-kdf

kdf
2008-01-30, 01:55
On 28-Nov-07, at 7:51 PM, peterw wrote:

> I think it'd probably be good if the normal model were to prepend the
> namespace to the HTML attributes, e.g.

Was a bug report ever filed on this? Please do, if only to avoid
losing track of the issue.
-kdf

gharris999
2008-01-30, 10:28
I don't think I should be the one to raise this bug, since the "help" that I provided Peter was along the lines of "Doh! It doesn't work!"

mherger
2008-01-30, 10:41
> I don't think I should be the one to raise this bug, since the "help"
> that I provided Peter was along the lines of "Doh! It doesn't work!"

C'mon! The contest is over. No need to be overly generous :-).

--

Michael

peterw
2008-01-30, 20:03
OK, bug filed at last: http://bugs.slimdevices.com/show_bug.cgi?id=6873

mherger
2008-04-25, 06:12
Done at revision 19155 (SC 7.1). Please note that this change will require some work in your plugins to be fully SC 7.1 compatible.