Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/force validation #603

Open
wants to merge 24 commits into
base: improve/variantCreationForm
Choose a base branch
from
Open
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ebcea74
Add $_SESSION entries for validated variants
loeswerkman Jun 9, 2022
ad3e048
Check whether variants are validated using $_SESSION
loeswerkman Jun 9, 2022
6b6dc8f
Fix issue in SQL queries
loeswerkman Jun 9, 2022
e23d860
Add documentation
loeswerkman Jun 9, 2022
2421eef
Add variants as keys instead of values to $_SESSION
loeswerkman Jun 9, 2022
55ce178
Fix issue concerning use of placeholders in SQL
loeswerkman Jun 9, 2022
cbb4822
Clean up code
loeswerkman Jun 9, 2022
d176f46
Trim reference sequence off at the mapping step
loeswerkman Jun 9, 2022
f6a7401
Check the correct $_SESSION variable at isset()
loeswerkman Jun 9, 2022
1de6020
Stop emptying all fields at each call
loeswerkman Jun 9, 2022
c1ac867
Stop removing the onChange of empty values
loeswerkman Jun 9, 2022
a5fb253
Update message on 'empty' fields
loeswerkman Jun 9, 2022
be47eb6
Make $sFieldName safe using htmlspecialchars()
loeswerkman Jun 10, 2022
d8b5ae0
Remove unnecessary urldecode()s
loeswerkman Jun 10, 2022
5f41d21
Add empty() around literal empty call
loeswerkman Jun 10, 2022
8c879af
Remove unnecessary global call
loeswerkman Jun 10, 2022
1d7f4c9
Use SQL's LEFT() instead of PHP's substr()
loeswerkman Jun 10, 2022
59f09d3
Check whether all expected $_REQUESTs were set
loeswerkman Jun 10, 2022
8590c12
Use function to add to $_SESSION & remove refseq
loeswerkman Jun 10, 2022
5380861
Check input using empty() instead of isset()
loeswerkman Jun 10, 2022
bd4733c
Clear up fixme
loeswerkman Jun 10, 2022
ae3563a
Remove todo that is no longer relevant
loeswerkman Jun 10, 2022
2f7ccf2
Move global call to top of the function
loeswerkman Jun 10, 2022
2f82e26
Invert wrong checks of required input
loeswerkman Jun 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/ajax/check_hgvs_dialogue.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,30 @@
header('Content-type: text/javascript; charset=UTF-8');


// Check whether all required input was given.
if (!(isset($_REQUEST['var']) && isset($_REQUEST['action'])
&& isset($_REQUEST['fieldName']) && isset($_REQUEST['refSeqInfo']))) {
// If any of these variables are missing, we cannot correctly
// perform any checks, so we will exit the script.
exit;
}
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
if (!isset($_REQUEST['transcripts'])) {
// Let's assume the transcripts were empty if this variable was not set.
$_REQUEST['transcripts'] = '';
}


loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
// Retrieving the transcripts to map to.
// We are using REQUEST and not GET or POST, because the
// input of this script can be both GET and POST.
$aTranscripts = (empty($_REQUEST['transcripts'])? array() : explode('|', urldecode($_REQUEST['transcripts'])));
$aTranscripts = (empty($_REQUEST['transcripts'])? array() : explode('|', $_REQUEST['transcripts']));

// Retrieving the name of the input field.
$sFieldName = htmlspecialchars(urldecode($_REQUEST['fieldName']));
$sFieldName = htmlspecialchars($_REQUEST['fieldName']);



if (!($_REQUEST['var'])) {
if (!empty($_REQUEST['var'])) {
// If the variant is empty, we can simply close the script.
exit;
}
loeswerkman marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -59,17 +72,16 @@
// found, we know that the input was the reference sequence
// of a transcript.
$sType = 'VOT';
$sReferenceSequence = urldecode($_REQUEST['refSeqInfo']);
global $_DB;
$sReferenceSequence = $_REQUEST['refSeqInfo'];
$bRefSeqIsSupportedByVV = (
'hg' == substr($_DB->query('SELECT id FROM ' . TABLE_GENOME_BUILDS . ' LIMIT 1')->fetchColumn(), 0, 2)
'hg' == $_DB->query('SELECT LEFT(id, 2) FROM ' . TABLE_GENOME_BUILDS . ' LIMIT 1')->fetchColumn()
);

} else {
// We know we got information on a GB. This is given through
// JS in the format of <genome build ID>-<chromosome>.
$sType = 'VOG';
list($sGenomeBuildID, $sChromosome) = explode('-', urldecode($_REQUEST['refSeqInfo']));
list($sGenomeBuildID, $sChromosome) = explode('-', $_REQUEST['refSeqInfo']);
$sReferenceSequence = (
!isset($_SETT['human_builds'][$sGenomeBuildID])?
'' : $_SETT['human_builds'][$sGenomeBuildID]['ncbi_sequences'][$sChromosome]
Expand Down