Revision 1f9ccef9
Added by koszko about 1 year ago
| common/entities.js | ||
|---|---|---|
| 117 | 117 |
#EXPORT get_used_files AS get_files |
| 118 | 118 |
|
| 119 | 119 |
/* |
| 120 |
* Regex to parse URIs like:
|
|
| 120 |
* Function to parse URIs like:
|
|
| 121 | 121 |
* https://hydrilla.koszko.org/schemas/api_mapping_description-2.schema.json |
| 122 | 122 |
*/ |
| 123 |
const name_base_re = "(?<name_base>[^/]*)";
|
|
| 124 |
const major_number_re = "(?<major>[1-9][0-9]*)";
|
|
| 123 |
const name_base_re = "([^/]*)"; |
|
| 124 |
const major_number_re = "([1-9][0-9]*)"; |
|
| 125 | 125 |
const minor_number_re = "(?:[1-9][0-9]*|0)"; |
| 126 | 126 |
const numbers_rest_re = `(?:\\.${minor_number_re})*`;
|
| 127 |
const version_re = `(?<ver>${major_number_re}${numbers_rest_re})`;
|
|
| 127 |
const version_re = `(${major_number_re}${numbers_rest_re})`;
|
|
| 128 | 128 |
const schema_name_re = `${name_base_re}-${version_re}\\.schema\\.json`;
|
| 129 | 129 |
|
| 130 |
const haketilo_schema_name_regex = new RegExp(schema_name_re); |
|
| 131 |
#EXPORT haketilo_schema_name_regex |
|
| 130 |
const schema_name_regex = new RegExp(schema_name_re); |
|
| 131 |
|
|
| 132 |
const schema_name_parts = ["full", "name_base", "version", "major"]; |
|
| 133 |
|
|
| 134 |
function parse_schema_uri(uri) {
|
|
| 135 |
const match = schema_name_regex.exec(uri); |
|
| 136 |
if (!match) |
|
| 137 |
return match; |
|
| 138 |
|
|
| 139 |
const result = {};
|
|
| 140 |
|
|
| 141 |
for (let i = 0; i < schema_name_parts.length; i++) |
|
| 142 |
result[schema_name_parts[i]] = match[i]; |
|
| 143 |
|
|
| 144 |
return result |
|
| 145 |
} |
|
| 146 |
#EXPORT parse_schema_uri |
|
| 132 | 147 |
|
| 133 | 148 |
/* Extract the number that indicates entity's compatibility mode. */ |
| 134 | 149 |
function get_schema_major_version(instance) {
|
| 135 |
const match = haketilo_schema_name_regex.exec(instance.$schema); |
|
| 136 |
|
|
| 137 |
return parseInt(match.groups.major); |
|
| 150 |
return parseInt(parse_schema_uri(instance.$schema).major); |
|
| 138 | 151 |
} |
| 139 | 152 |
#EXPORT get_schema_major_version |
| 140 | 153 |
|
| common/jsonschema.js | ||
|---|---|---|
| 57 | 57 |
|
| 58 | 58 |
#FROM common/jsonschema/scan.js IMPORT SchemaScanResult, scan |
| 59 | 59 |
|
| 60 |
#FROM common/entities.js IMPORT haketilo_schema_name_regex
|
|
| 60 |
#FROM common/entities.js IMPORT parse_schema_uri
|
|
| 61 | 61 |
|
| 62 | 62 |
#EXPORT scan |
| 63 | 63 |
#EXPORT SchemaScanResult |
| ... | ... | |
| 89 | 89 |
].reduce((ac, s) => Object.assign(ac, {[s.$id]: s}), {});
|
| 90 | 90 |
|
| 91 | 91 |
for (const [$id, schema] of [...Object.entries(haketilo_schemas)]) {
|
| 92 |
const match = haketilo_schema_name_regex.exec($id); |
|
| 93 |
const schema_name = |
|
| 94 |
`${match.groups.name_base}-${match.groups.major}.schema.json`;
|
|
| 92 |
const parsed = parse_schema_uri($id); |
|
| 93 |
const schema_name = `${parsed.name_base}-${parsed.major}.schema.json`;
|
|
| 95 | 94 |
haketilo_schemas[schema_name] = schema; |
| 96 | 95 |
} |
| 97 | 96 |
|
| html/install.js | ||
|---|---|---|
| 50 | 50 |
#FROM common/entities.js IMPORT item_id_string, version_string, get_files |
| 51 | 51 |
#FROM common/misc.js IMPORT sha256_async AS compute_sha256 |
| 52 | 52 |
#FROM common/jsonschema.js IMPORT haketilo_validator, haketilo_schemas |
| 53 |
#FROM common/entities.js IMPORT haketilo_schema_name_regex
|
|
| 53 |
#FROM common/entities.js IMPORT parse_schema_uri
|
|
| 54 | 54 |
|
| 55 | 55 |
#FROM html/repo_query_cacher_client.js IMPORT indirect_fetch |
| 56 | 56 |
|
| ... | ... | |
| 208 | 208 |
`${captype} ${item_id_string(id, ver)} was served using a nonconforming response format.`;
|
| 209 | 209 |
|
| 210 | 210 |
try {
|
| 211 |
const match = haketilo_schema_name_regex.exec(json.$schema);
|
|
| 212 |
var major_schema_version = match.groups.major;
|
|
| 211 |
const parsed = parse_schema_uri(json.$schema);
|
|
| 212 |
var major_schema_version = parsed.major;
|
|
| 213 | 213 |
|
| 214 | 214 |
if (!["1", "2"].includes(major_schema_version)) {
|
| 215 | 215 |
const msg = `${captype} ${item_id_string(id, ver)} was served using unsupported Hydrilla API version. You might need to update Haketilo.`;
|
| test/haketilo_test/profiles.py | ||
|---|---|---|
| 81 | 81 |
json.dumps({extension_id: uuid}))
|
| 82 | 82 |
|
| 83 | 83 |
def firefox_safe_mode(proxy_port, proxy_host=default_proxy_host, |
| 84 |
firefox_binary=conf_settings['BROWSER_BINARY']): |
|
| 84 |
firefox_binary=conf_settings['BROWSER_BINARY'], |
|
| 85 |
geckodriver_binary=conf_settings['DRIVER']): |
|
| 85 | 86 |
""" |
| 86 | 87 |
Initialize a Firefox instance controlled by selenium. The instance is |
| 87 | 88 |
started in safe mode. |
| ... | ... | |
| 94 | 95 |
options.add_argument('--safe-mode')
|
| 95 | 96 |
|
| 96 | 97 |
return HaketiloFirefox(options=options, firefox_profile=profile, |
| 97 |
firefox_binary=firefox_binary) |
|
| 98 |
firefox_binary=firefox_binary, |
|
| 99 |
executable_path=geckodriver_binary) |
|
| 98 | 100 |
|
| 99 | 101 |
def firefox_with_profile(proxy_port, proxy_host=default_proxy_host, |
| 100 | 102 |
firefox_binary=conf_settings['BROWSER_BINARY'], |
| 101 |
profile_dir=conf_settings['CLEAN_PROFILE']): |
|
| 103 |
profile_dir=conf_settings['CLEAN_PROFILE'], |
|
| 104 |
geckodriver_binary=conf_settings['DRIVER']): |
|
| 102 | 105 |
""" |
| 103 | 106 |
Initialize a Firefox instance controlled by selenium. The instance is |
| 104 | 107 |
started using an empty profile (either the default one or the one passed to |
| ... | ... | |
| 111 | 114 |
set_webextension_uuid(profile, default_haketilo_id) |
| 112 | 115 |
|
| 113 | 116 |
return HaketiloFirefox(firefox_profile=profile, |
| 114 |
firefox_binary=firefox_binary) |
|
| 117 |
firefox_binary=firefox_binary, |
|
| 118 |
executable_path=geckodriver_binary) |
|
Also available in: Unified diff
restore compatibility with IceCat 60
This commit also fixes the --driver option to configure script.