View | Details | Raw Unified | Return to bug 27933
Collapse All | Expand All

(-)a/C4/Utils/DataTables.pm (-2 / +2 lines)
Lines 104-111 sub dt_build_orderby { Link Here
104
104
105
    return unless @orderbys;
105
    return unless @orderbys;
106
106
107
    # Must be "branches.branchname asc", "borrowers.firstname desc", etc.
107
    # Must be "branches.branchname asc", "borrowers.firstname desc", "dateofbirth asc" etc.
108
    @orderbys = grep { /^\w+\.\w+ (asc|desc)$/ } @orderbys;
108
    @orderbys = grep { /^\w*\.?\w+ (asc|desc)$/ } @orderbys;
109
109
110
    my @sanitized_orderbys;
110
    my @sanitized_orderbys;
111
    for my $orderby (@orderbys) {
111
    for my $orderby (@orderbys) {
(-)a/t/db_dependent/Utils/Datatables.t (-2 / +11 lines)
Lines 32-38 $schema->storage->txn_begin; Link Here
32
my $builder = t::lib::TestBuilder->new;
32
my $builder = t::lib::TestBuilder->new;
33
33
34
subtest 'dt_build_orderby' => sub {
34
subtest 'dt_build_orderby' => sub {
35
    plan tests => 2;
35
    plan tests => 3;
36
36
37
    my $dt_params = {
37
    my $dt_params = {
38
        iSortCol_0  => 5,
38
        iSortCol_0  => 5,
Lines 58-61 subtest 'dt_build_orderby' => sub { Link Here
58
58
59
    $orderby = dt_build_orderby($dt_params);
59
    $orderby = dt_build_orderby($dt_params);
60
    is( $orderby, " ORDER BY `branches`.`branchname` ASC,`borrowers`.`surname` DESC,`borrowers`.`firstname` DESC ", 'ORDER BY has been correctly built, even with invalid stuff');
60
    is( $orderby, " ORDER BY `branches`.`branchname` ASC,`borrowers`.`surname` DESC,`borrowers`.`firstname` DESC ", 'ORDER BY has been correctly built, even with invalid stuff');
61
62
    $dt_params = {
63
        iSortCol_0  => 1,
64
        sSortDir_0  => "asc",
65
        mDataProp_1 => "dateofbirth",
66
        name_sorton => "dateofbirth asc",
67
    };
68
69
    $orderby = dt_build_orderby($dt_params);
70
    is( $orderby, " ORDER BY `dateofbirth` ASC ", 'ORDER BY has been correctly built' );
61
};
71
};
62
- 

Return to bug 27933