Skip to content

Commit

Permalink
Merge pull request #164 from chamil321/test-fail
Browse files Browse the repository at this point in the history
Fix wantCode user input
  • Loading branch information
chamil321 authored Jul 29, 2020
2 parents 497bcc8 + e9acfbd commit 6b53487
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions subscriber/src/subscriber/save.bal
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function saveImagePdf(map<json> imageJson) {
# + return - returns the base name for the file
function getPresidentialFileNameBase(string electionCode, map<json> result) returns string {
// start with sequence # and type code
string name = (wantCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" +
string name = (addCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" +
(result.'type.toString() == PRESIDENTIAL_RESULT ? "PE1" : "PE2") + "-";

string resultLevel = result.level.toString();
Expand Down Expand Up @@ -140,7 +140,7 @@ function getPresidentialFileNameBase(string electionCode, map<json> result) retu
# + return - returns the base name for the file
function getParliamentaryFileNameBase(string electionCode, map<json> result) returns string {
// start with sequence # and type code
string name = (wantCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" +
string name = (addCode ? electionCode + "-" : "") + result.sequence_number.toString() + "-" +
result.'type.toString() + "-";

string resultLevel = result.level.toString();
Expand Down
5 changes: 4 additions & 1 deletion subscriber/src/subscriber/subscriber.bal
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ boolean wantXml = false;
boolean wantHtml = false;
boolean sortedHtml = false;

boolean wantCode = false;
boolean addCode = false;

public type ElectionType ELECTION_TYPE_PRESIDENTIAL|ELECTION_TYPE_PARLIAMENTARY;

Expand Down Expand Up @@ -39,6 +39,9 @@ public function main (string? username = (), // my username
generateHtml = generateParliamentaryResultHtml;
}

// check whether the user wants electionCode in the filename
addCode = <@untainted>wantCode;

// check what format the user wants results in
wantJson = <@untainted>'json;
wantXml = <@untainted>'xml;
Expand Down

0 comments on commit 6b53487

Please sign in to comment.