Skip to content

Commit

Permalink
json encode valid characters
Browse files Browse the repository at this point in the history
so escaped characters don't get changed back to plain characters
  • Loading branch information
70ray committed Dec 27, 2024
1 parent 15d9310 commit 5bff820
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions quiz/generic/proof.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
}
// 'quiz' will result in codepoints for quizzes
$quiz = get_project_or_quiz("quiz");
$valid_character_pattern = build_character_regex_filter($quiz->get_valid_codepoints(), "js");
$valid_character_pattern = json_encode(build_character_regex_filter($quiz->get_valid_codepoints(), "js"));

$header_args = [
"js_files" => [
"$code_url/tools/proofers/process_diacritcal_markup.js",
"$code_url/tools/proofers/text_data_processor.js",
],
"js_data" => "
var validCharacterPattern = '$valid_character_pattern';
var validCharacterPattern = $valid_character_pattern;
",
'body_attributes' => "onload='top.initializeStuff(1)'",
];
Expand Down
4 changes: 2 additions & 2 deletions tools/project_manager/handle_bad_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
$header = _("Fix Page");
}

$valid_character_pattern = build_character_regex_filter($project->get_valid_codepoints(), "js");
$valid_character_pattern = json_encode(build_character_regex_filter($project->get_valid_codepoints(), "js"));
$header_args = [
"js_files" => [
"$code_url/pinc/3rdparty/xregexp/xregexp-all.js",
Expand All @@ -88,7 +88,7 @@
"$code_url/tools/project_manager/handle_bad_page.js",
],
"js_data" => "
var validCharacterPattern = '$valid_character_pattern';
var validCharacterPattern = $valid_character_pattern;
",
];

Expand Down
4 changes: 2 additions & 2 deletions tools/proofers/proof_frame_enh.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function echo_proof_frame_enh(PPage $ppage): void
global $code_url;

$project = new Project($ppage->projectid());
$valid_character_pattern = build_character_regex_filter($project->get_valid_codepoints(), "js");
$valid_character_pattern = json_encode(build_character_regex_filter($project->get_valid_codepoints(), "js"));
$switch_confirm = json_encode(_('Are you sure you want to save the current page and change layout?'));
$revert_confirm = json_encode(_("Are you sure you want to save the current page and revert to the original text for this round?"));

Expand Down Expand Up @@ -46,7 +46,7 @@ function echo_proof_frame_enh(PPage $ppage): void
function ldAll() {
top.initializeStuff(1);
}
var validCharacterPattern = '$valid_character_pattern';
var validCharacterPattern = $valid_character_pattern;
var standardInterface = false;
var switchConfirm = '$switch_confirm';
var revertConfirm = '$revert_confirm';
Expand Down
4 changes: 2 additions & 2 deletions tools/proofers/spellcheck_text.inc
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function get_wordcheck_page_header_args(User $user, PPage $ppage): array
global $code_url, $word_check_messages;

$project = new Project($ppage->projectid());
$valid_character_pattern = build_character_regex_filter($project->get_valid_codepoints(), "js");
$valid_character_pattern = json_encode(build_character_regex_filter($project->get_valid_codepoints(), "js"));

$storage_key = "proof-enh" . (($user->profile->i_layout == 1) ? "-v" : "-h");

Expand All @@ -632,7 +632,7 @@ function get_wordcheck_page_header_args(User $user, PPage $ppage): array
"js_data" => get_page_js($user->profile->i_type == 1 ? 2 : 3) .
get_control_bar_texts() . "
var imageData = $image_data;
var validCharacterPattern = '$valid_character_pattern';
var validCharacterPattern = $valid_character_pattern;
var wordCheckMessages = " . json_encode($word_check_messages) . ";
",

Expand Down
4 changes: 2 additions & 2 deletions tools/proofers/text_frame_std.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function echo_text_frame_std(PPage $ppage): void
global $code_url;

$project = new Project($ppage->projectid());
$valid_character_pattern = build_character_regex_filter($project->get_valid_codepoints(), "js");
$valid_character_pattern = json_encode(build_character_regex_filter($project->get_valid_codepoints(), "js"));
$switch_confirm = json_encode(_('Are you sure you want to save the current page and change layout?'));
$revert_confirm = json_encode(_("Are you sure you want to save the current page and revert to the original text for this round?"));

Expand All @@ -29,7 +29,7 @@ function echo_text_frame_std(PPage $ppage): void
function ldAll() {
top.initializeStuff(0);
}
var validCharacterPattern = '$valid_character_pattern';
var validCharacterPattern = $valid_character_pattern;
var standardInterface = true;
var switchConfirm = '$switch_confirm';
var revertConfirm = '$revert_confirm';
Expand Down

0 comments on commit 5bff820

Please sign in to comment.