Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
database system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
7 Dec 2007 at 19:39 UTC
Updated:
18 Jan 2008 at 09:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
hswong3i commentedstatistics_title_list():
totalcount,daycountandtimestampare INT, so should use0(integer compare) instead of'0'(string compare).system_cron():
statusand query argument are INT, so should use %d instead of %s.Comment #2
hswong3i commentedI mark this into my personal research project issue.
Comment #3
hswong3i commentedPatch reroll via latest CVS HEAD. Test without ill effect.
Comment #4
hswong3i commentedJust hope to promote if we are able to fix this within D6 RC1.
Comment #5
gábor hojtsyNot critical. The system module hunk looks good, but the other one makes the dbfield unsanitized and therefore a source of possible SQL injection the value needs to be stanitized.
Comment #6
hswong3i commented(I merge http://drupal.org/node/199214 with this issue.)
I try to use db_escape_table(): correct in syntax and function, but not logically suitable (we hope to escape column, not table)...
I try to folk db_escape_table() as db_escape_column(): this seems too ugly and not elegant...
Finally, I try rename db_escape_table() as db_escape_constraint(). As term "constraint" is a superset of "table" and "column", the meaning should be more suitable and general. I dig into all core code, and found that db_escape_table() is now used as internal, only. Hope this change would be acceptable.
Comment #7
gábor hojtsyNo, we are not doing API changes this late in the cycle. Contributed modules could just as well use this just as we do.
Comment #8
hswong3i commentedActually... totally agree...
So may I ask for some suggestion? Should I reuse db_escape_table() for incorrect meaning, or folk it as db_escape_column() for a not elegant handling? Either one solution should function correctly.
P.S. maybe we can use embed checking within each function. This should be the least impact to API, but most ugly...
Comment #9
hswong3i commentedFolk db_escape_table() as db_escape_column().
Comment #10
hswong3i commentedIf a simple documentation can solve this logical conflict, it should be the most simple solution?
Comment #11
chx commentedAs Siren is not a project on Drupal.org but an unofficial fork, I am removing it from issue titles to avoid confusion.
Comment #12
hswong3i commentedPatch update and reroll via CVS HEAD. Bugfix with:
.asalias.columnsyntax. It is a special case and so need special handling.Comment #13
hswong3i commentedFix database.pgsql.inc miss handling.
Comment #14
gábor hojtsy- All this
call() ? TRUE : FALSEjumbo could easily be done with(bool) call();much more nicely.- I don't understand how the implode() in the tablesort code is better
- Also, why/how are the patterns in the tablesort code are correct? You seem to keep realizing missed use cases, so it seems like a restrictive white list approach.
Comment #15
hswong3i commentedSome update:
Comment #16
gábor hojtsyOK, looked into the tablesort_sql() case:
- $ts['sql'] seems to be a column name... very bad variable name... why don't you use the usual column name escape then?
- why do you need to do this magic on $ts['sort']? IMHO we should ensure in tablesort_get_sort() that we only return 'asc' or 'desc', and then we can do the same check here as well, as we aim to protect the API from possible SQL injection here as well
Comment #17
hswong3i commented- I hate $ts['sql'] too... so rename it as $ts['field'] (I don't know if this will void the rule of not changing API...). It is used internally, and tested as function. On the other hand, as $ts['field'] may represent in "alias.field" format, it is different from normal column filtering.
- Now I give a more explicitly checking for $ts['sort']: only allow ASC or DESC.
Comment #18
gábor hojtsyYes, changing the array key name counts as an API change, so we should not do it. But changing the internal variable name in tablesort_sql() is not an API change and should be done.
When you have two possible values, in_array($value, array('ASC'? 'DESC')) is much cleaner and quicker then preg-replacing whatever. Why complicate this?
Comment #19
hswong3i commentedI am also finding for a better solution... Thanks for your suggestion :)
P.S. Should I update statistics_title_list() into in_array() handling? Seems we only allow 3 choices.
Comment #20
gábor hojtsy- How on earth is statistics_title_list() related? Keep the issue focused.
- I said renaming the array index is an API change, as it is used across the different tablesort functions.
Comment #21
hswong3i commented- statistics_title_list() is related because it use %s for column name filtering, which is also included in previous patches. Since we only allow 'totalcount', 'daycount' and 'timestamp' as valid $dbfield input, I guess we should also use in_array() for a faster and explicitly checking.
- Sorry for misunderstanding, and array key is now keep as unchanged. Only fix function internal variable naming.
Comment #22
hswong3i commentedAdditional minor catch in database.pgsql.inc: db_last_insert_id() is in similar case and so change handle with db_escape_table().
Comment #23
gábor hojtsyOK, modified the docs included, and committed this.
Comment #24
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.