This repository was archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpreferenceStringContainer.js
More file actions
110 lines (96 loc) · 3.2 KB
/
Copy pathpreferenceStringContainer.js
File metadata and controls
110 lines (96 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
Copyright 2007 Security Compass
This file is part of SQL Inject Me.
SQL Inject Me is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SQL Inject Me is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SQL Inject Me. If not, see <http://www.gnu.org/licenses/>.
If you have any questions regarding SQL Inject Me please contact
tools@securitycompass.com
*/
/**
* preferenceStringContainer.js
* requires JSON.
*/
/**
* the PreferenceStringContainer object is a base class for any kind of object
* which has deal with an array of strings held in preferences.
* (e.g. AttackStringContainer, ResultStringContainer).
*/
function PreferenceStringContainer() {
this.strings = Array();
this.prefBranch = null;
this.prefService = Components.classes['@mozilla.org/preferences-service;1'].
getService(Components.interfaces.nsIPrefService);
}
dump('creating... preferenceStringContainer object\n');
PreferenceStringContainer.prototype = {
/**
* init is responsible for reading and loading a preference into
*/
init: function() {
}
,
getStrings: function(force){
if (force === true){
this.init();
}
return this.strings;
}
,
addString: function(string, signature) {
dump('PreferenceStringContainer::addString: ' + string+ ' ' + signature + '\n');
if (!string) {
return false;
}
var preference = new Object();
preference.string = string;
preference.sig = signature;
if (this.strings.every(checkUnique, preference)){
this.strings.push(preference);
dump('PreferenceStringContainer::addString preference == ' +
preference + '\n');
this.save();
return true;
}
else {
return false;
}
}
,
/**
* save is responsible for taking this.strings and saving it into
* preferences.
*/
save: function() {
}
,
swap: function (index1, index2){
if (typeof(this.strings[index1]) === "undefined" ||
this.strings[index1] === null ||
typeof(this.strings[index2]) === "undefined" ||
this.strings[index2] === null)
{
return false;
}
[this.strings[index2], this.strings[index1]] =
[this.strings[index1], this.strings[index2]]
this.save();
return true;
}
};
/**
* used by addString to ensure that a given (in this.string) is not in the
* container
*/
function checkUnique(element, index, array){
dump("checkunique: " + (this.string) + " " + (element.string) + " \n");
dump("checkunique: " + (this.string != element.string) + " \n");
return this.string != element.string;
}