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

(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-6 / +7 lines)
Lines 579-585 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
579
                                function build_query(col, value){
579
                                function build_query(col, value){
580
580
581
                                    // escape SQL special characters
581
                                    // escape SQL special characters
582
                                    value = value.replace(/(\%|\_|\\)/g, "\\$1" );
582
                                    value_escaped = value.replace(/\\/g, "\\$1" );
583
                                    // escape SQL LIKE special characters
584
                                    value_like_escaped = value.replace(/(\%|\_|\\)/g, "\\$1");
583
585
584
                                    var parts = [];
586
                                    var parts = [];
585
                                    var attributes = col.data.split(':');
587
                                    var attributes = col.data.split(':');
Lines 587-599 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
587
                                        var part = {};
589
                                        var part = {};
588
                                        var attr = attributes[i];
590
                                        var attr = attributes[i];
589
                                        let criteria = options.criteria;
591
                                        let criteria = options.criteria;
590
                                        if ( value.match(/^\^(.*)\$$/) ) {
592
                                        if ( value_escaped.match(/^\^(.*)\$$/) ) {
591
                                            value = value.replace(/^\^/, '').replace(/\$$/, '');
593
                                            value_escaped = value_escaped.replace(/^\^/, '').replace(/\$$/, '');
592
                                            criteria = "exact";
594
                                            criteria = "exact";
593
                                        }
595
                                        }
594
                                        part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact'
596
                                        part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact'
595
                                            ? value
597
                                            ? value_escaped
596
                                            : {like: (['contains', 'ends_with'].indexOf(criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(criteria) !== -1?'%':'')};
598
                                            : {like: (['contains', 'ends_with'].indexOf(criteria) !== -1?'%':'') + value_like_escaped + (['contains', 'starts_with'].indexOf(criteria) !== -1?'%':'')};
597
                                        parts.push(part);
599
                                        parts.push(part);
598
                                    }
600
                                    }
599
                                    return parts;
601
                                    return parts;
600
- 

Return to bug 31565