From 734f18224271c1219b73b4aaa27cb0d32233a58d Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 20 Jul 2020 18:25:22 -0400 Subject: [PATCH 1/5] Update error messages to use the built in assertEquals --- src/test/java/org/json/junit/Util.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/json/junit/Util.java b/src/test/java/org/json/junit/Util.java index 2e8f6be93..8dc27ddfa 100644 --- a/src/test/java/org/json/junit/Util.java +++ b/src/test/java/org/json/junit/Util.java @@ -103,20 +103,18 @@ private static void compareActualVsExpectedObjects(Object value, */ if (!(value instanceof Number && expectedValue instanceof Number)) { // Non-Number and non-matching types - assertTrue("object types should be equal for actual: "+ - value.toString()+" ("+ - value.getClass().toString()+") expected: "+ - expectedValue.toString()+" ("+ - expectedValue.getClass().toString()+")", - value.getClass().toString().equals( - expectedValue.getClass().toString())); + assertEquals("object types should be equal ", + expectedValue.getClass().toString(), + value.getClass().toString() + ); } /** * Same types or both Numbers, compare by toString() */ - assertTrue("string values should be equal for actual: "+ - value.toString()+" expected: "+expectedValue.toString(), - value.toString().equals(expectedValue.toString())); + assertEquals("values should be equal", + expectedValue.toString(), + value.toString() + ); } } } From c98da43184834304b8eaaea3d10bd4f5b653444d Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 20 Jul 2020 18:25:51 -0400 Subject: [PATCH 2/5] Refs #537 Add test cases to verify no issue --- src/test/java/org/json/junit/XMLTest.java | 41 +++++ src/test/resources/Issue537.json | 189 ++++++++++++++++++++ src/test/resources/Issue537.xml | 203 ++++++++++++++++++++++ 3 files changed, 433 insertions(+) create mode 100644 src/test/resources/Issue537.json create mode 100644 src/test/resources/Issue537.xml diff --git a/src/test/java/org/json/junit/XMLTest.java b/src/test/java/org/json/junit/XMLTest.java index d59496133..bc4829922 100644 --- a/src/test/java/org/json/junit/XMLTest.java +++ b/src/test/java/org/json/junit/XMLTest.java @@ -34,12 +34,15 @@ of this software and associated documentation files (the "Software"), to deal import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.json.JSONTokener; import org.json.XML; import org.json.XMLParserConfiguration; import org.junit.Rule; @@ -898,4 +901,42 @@ public void testToJsonWithNullWhenNilConversionDisabled() { final JSONObject json = XML.toJSONObject(originalXml, new XMLParserConfiguration()); assertEquals(expectedJsonString, json.toString()); } + + /** + * Tests to verify that supported escapes in XML are converted to actual values. + */ + @Test + public void testIssue537CaseSensitiveHexEscapeMinimal(){ + String xmlStr = + "\n"+ + "Neutrophils.Hypersegmented | Bld-Ser-Plas"; + String expectedStr = + "{\"root\":\"Neutrophils.Hypersegmented | Bld-Ser-Plas\"}"; + JSONObject xmlJSONObj = XML.toJSONObject(xmlStr, true); + JSONObject expected = new JSONObject(expectedStr); + Util.compareActualVsExpectedJsonObjects(xmlJSONObj, expected); + } + + /** + * Tests to verify that supported escapes in XML are converted to actual values. + */ + @Test + public void testIssue537CaseSensitiveHexEscapeFullFile(){ + try { + try( + InputStream xmlStream = XMLTest.class.getClassLoader().getResourceAsStream("Issue537.xml"); + Reader xmlReader = new InputStreamReader(xmlStream); + ){ + JSONObject actual = XML.toJSONObject(xmlReader, true); + try( + InputStream jsonStream = XMLTest.class.getClassLoader().getResourceAsStream("Issue537.json"); + ){ + final JSONObject expected = new JSONObject(new JSONTokener(jsonStream)); + Util.compareActualVsExpectedJsonObjects(actual,expected); + } + } + } catch (IOException e) { + fail("file writer error: " +e.getMessage()); + } + } } \ No newline at end of file diff --git a/src/test/resources/Issue537.json b/src/test/resources/Issue537.json new file mode 100644 index 000000000..bf902873b --- /dev/null +++ b/src/test/resources/Issue537.json @@ -0,0 +1,189 @@ +{ + "clinical_study": { + "brief_summary": { + "textblock": "CLEAR SYNERGY is an international multi center 2x2 randomized placebo controlled trial of\r\n colchicine and spironolactone in patients with STEMI. Subjects enrolled in the main CLEAR\r\n SYNERGY trial will be asked to participate in this sub study (n=670) to undergo:\r\n\r\n 1. Evaluation of markers of neutrophil activity at randomization (baseline) and 3 months\r\n follow-up in the colchicine versus placebo groups, and;\r\n\r\n 2. Examination of clinical and genetic factors that determine heterogeneity of treatment\r\n response and distinguish colchicine responders from non- responders.\r\n\r\n Participants undergo a blood draw at baseline and 3 months follow-up as part of the main\r\n trial, and participants who also participate in this sub study will have an additional 2\r\n tablespoons of blood drawn.\r\n\r\n The sub study objectives are to:\r\n\r\n 1. Assess the effect of colchicine on neutrophil activation in response to STEMI.\r\n\r\n 2. Examine clinical and genetic factors that determine heterogeneity of treatment response\r\n anddistinguish colchicine responders from non- responders.\r\n\r\n 3. Explore the derivation of a risk score that includes markers of neutrophil activity and\r\n is associated with adjudicated MACE over 3 years after STEMI, and assess the impact of\r\n colchicine on the relation between this risk score and MACE." + }, + "brief_title": "CLEAR SYNERGY Neutrophil Substudy", + "overall_status": "Recruiting", + "eligibility": { + "study_pop": { + "textblock": "Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) trial\r\n will be eligible for participation in this Neutrophil biomarker substudy. These are\r\n patients who present with STEMI." + }, + "minimum_age": "19 Years", + "sampling_method": "Non-Probability Sample", + "gender": "All", + "criteria": { + "textblock": "Inclusion Criteria:\r\n\r\n - Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9)\r\n trial will be eligible for participation in this Neutrophil biomarker substudy.\r\n\r\n Exclusion Criteria:\r\n\r\n - Use of anti-inflammatory agents (except aspirin)\r\n\r\n - Active infection" + }, + "healthy_volunteers": "No", + "maximum_age": "110 Years" + }, + "number_of_groups": "2", + "source": "NYU Langone Health", + "location_countries": { + "country": "United States" + }, + "study_design_info": { + "time_perspective": "Prospective", + "observational_model": "Other" + }, + "last_update_submitted_qc": "September 10, 2019", + "intervention_browse": { + "mesh_term": "Colchicine" + }, + "official_title": "Studies on the Effects of Colchicine on Neutrophil Biology in Acute Myocardial Infarction: A Substudy of the CLEAR SYNERGY (OASIS 9) Trial", + "primary_completion_date": { + "type": "Anticipated", + "content": "February 1, 2021" + }, + "sponsors": { + "lead_sponsor": { + "agency_class": "Other", + "agency": "NYU Langone Health" + }, + "collaborator": [ + { + "agency_class": "Other", + "agency": "Population Health Research Institute" + }, + { + "agency_class": "NIH", + "agency": "National Heart, Lung, and Blood Institute (NHLBI)" + } + ] + }, + "overall_official": { + "role": "Principal Investigator", + "affiliation": "NYU School of Medicine", + "last_name": "Binita Shah, MD" + }, + "overall_contact_backup": { + "last_name": "Binita Shah, MD" + }, + "condition_browse": { + "mesh_term": [ + "Myocardial Infarction", + "ST Elevation Myocardial Infarction", + "Infarction" + ] + }, + "overall_contact": { + "phone": "646-501-9648", + "last_name": "Fatmira Curovic", + "email": "fatmira.curovic@nyumc.org" + }, + "responsible_party": { + "responsible_party_type": "Principal Investigator", + "investigator_title": "Assistant Professor of Medicine", + "investigator_full_name": "Binita Shah", + "investigator_affiliation": "NYU Langone Health" + }, + "study_first_submitted_qc": "March 12, 2019", + "start_date": { + "type": "Actual", + "content": "March 4, 2019" + }, + "has_expanded_access": "No", + "study_first_posted": { + "type": "Actual", + "content": "March 14, 2019" + }, + "arm_group": [ + { + "arm_group_label": "Colchicine" + }, + { + "arm_group_label": "Placebo" + } + ], + "primary_outcome": { + "measure": "soluble L-selectin", + "time_frame": "between baseline and 3 months", + "description": "Change in soluble L-selectin between baseline and 3 mo after STEMI in the placebo vs. colchicine groups." + }, + "secondary_outcome": [ + { + "measure": "Other soluble markers of neutrophil activity", + "time_frame": "between baseline and 3 months", + "description": "Other markers of neutrophil activity will be evaluated at baseline and 3 months after STEMI (myeloperoxidase, matrix metalloproteinase-9, neutrophil gelatinase-associated lipocalin, neutrophil elastase, intercellular/vascular cellular adhesion molecules)" + }, + { + "measure": "Markers of systemic inflammation", + "time_frame": "between baseline and 3 months", + "description": "Markers of systemic inflammation will be evaluated at baseline and 3 months after STEMI (high sensitive CRP, IL-1β)" + }, + { + "measure": "Neutrophil-driven responses that may further propagate injury", + "time_frame": "between baseline and 3 months", + "description": "Neutrophil-driven responses that may further propagate injury will be evaluated at baseline and 3 months after STEMI (neutrophil extracellular traps, neutrophil-derived microparticles)" + } + ], + "oversight_info": { + "is_fda_regulated_drug": "No", + "is_fda_regulated_device": "No", + "has_dmc": "No" + }, + "last_update_posted": { + "type": "Actual", + "content": "September 12, 2019" + }, + "id_info": { + "nct_id": "NCT03874338", + "org_study_id": "18-01323", + "secondary_id": "1R01HL146206" + }, + "enrollment": { + "type": "Anticipated", + "content": "670" + }, + "study_first_submitted": "March 12, 2019", + "condition": [ + "Neutrophils.Hypersegmented | Bld-Ser-Plas", + "STEMI - ST Elevation Myocardial Infarction" + ], + "study_type": "Observational", + "required_header": { + "download_date": "ClinicalTrials.gov processed this data on July 19, 2020", + "link_text": "Link to the current ClinicalTrials.gov record.", + "url": "https://clinicaltrials.gov/show/NCT03874338" + }, + "last_update_submitted": "September 10, 2019", + "completion_date": { + "type": "Anticipated", + "content": "February 1, 2022" + }, + "location": { + "contact": { + "phone": "646-501-9648", + "last_name": "Fatmira Curovic", + "email": "fatmira.curovic@nyumc.org" + }, + "facility": { + "address": { + "zip": "10016", + "country": "United States", + "city": "New York", + "state": "New York" + }, + "name": "NYU School of Medicine" + }, + "status": "Recruiting", + "contact_backup": { + "last_name": "Binita Shah, MD" + } + }, + "intervention": { + "intervention_type": "Drug", + "arm_group_label": [ + "Colchicine", + "Placebo" + ], + "description": "Participants in the main CLEAR SYNERGY trial are randomized to colchicine/spironolactone versus placebo in a 2x2 factorial design. The substudy is interested in the evaluation of biospecimens obtained from patients in the colchicine vs placebo group.", + "intervention_name": "Colchicine Pill" + }, + "patient_data": { + "sharing_ipd": "No" + }, + "verification_date": "September 2019" + } +} \ No newline at end of file diff --git a/src/test/resources/Issue537.xml b/src/test/resources/Issue537.xml new file mode 100644 index 000000000..9561234a8 --- /dev/null +++ b/src/test/resources/Issue537.xml @@ -0,0 +1,203 @@ + + + + + ClinicalTrials.gov processed this data on July 19, 2020 + Link to the current ClinicalTrials.gov record. + https://clinicaltrials.gov/show/NCT03874338 + + + 18-01323 + 1R01HL146206 + NCT03874338 + + CLEAR SYNERGY Neutrophil Substudy + Studies on the Effects of Colchicine on Neutrophil Biology in Acute Myocardial Infarction: A Substudy of the CLEAR SYNERGY (OASIS 9) Trial + + + NYU Langone Health + Other + + + Population Health Research Institute + Other + + + National Heart, Lung, and Blood Institute (NHLBI) + NIH + + + NYU Langone Health + + No + No + No + + + + CLEAR SYNERGY is an international multi center 2x2 randomized placebo controlled trial of + colchicine and spironolactone in patients with STEMI. Subjects enrolled in the main CLEAR + SYNERGY trial will be asked to participate in this sub study (n=670) to undergo: + + 1. Evaluation of markers of neutrophil activity at randomization (baseline) and 3 months + follow-up in the colchicine versus placebo groups, and; + + 2. Examination of clinical and genetic factors that determine heterogeneity of treatment + response and distinguish colchicine responders from non- responders. + + Participants undergo a blood draw at baseline and 3 months follow-up as part of the main + trial, and participants who also participate in this sub study will have an additional 2 + tablespoons of blood drawn. + + The sub study objectives are to: + + 1. Assess the effect of colchicine on neutrophil activation in response to STEMI. + + 2. Examine clinical and genetic factors that determine heterogeneity of treatment response + anddistinguish colchicine responders from non- responders. + + 3. Explore the derivation of a risk score that includes markers of neutrophil activity and + is associated with adjudicated MACE over 3 years after STEMI, and assess the impact of + colchicine on the relation between this risk score and MACE. + + + Recruiting + March 4, 2019 + February 1, 2022 + February 1, 2021 + Observational + No + + Other + Prospective + + + soluble L-selectin + between baseline and 3 months + Change in soluble L-selectin between baseline and 3 mo after STEMI in the placebo vs. colchicine groups. + + + Other soluble markers of neutrophil activity + between baseline and 3 months + Other markers of neutrophil activity will be evaluated at baseline and 3 months after STEMI (myeloperoxidase, matrix metalloproteinase-9, neutrophil gelatinase-associated lipocalin, neutrophil elastase, intercellular/vascular cellular adhesion molecules) + + + Markers of systemic inflammation + between baseline and 3 months + Markers of systemic inflammation will be evaluated at baseline and 3 months after STEMI (high sensitive CRP, IL-1β) + + + Neutrophil-driven responses that may further propagate injury + between baseline and 3 months + Neutrophil-driven responses that may further propagate injury will be evaluated at baseline and 3 months after STEMI (neutrophil extracellular traps, neutrophil-derived microparticles) + + 2 + 670 + Neutrophils.Hypersegmented | Bld-Ser-Plas + STEMI - ST Elevation Myocardial Infarction + + Colchicine + + + Placebo + + + Drug + Colchicine Pill + Participants in the main CLEAR SYNERGY trial are randomized to colchicine/spironolactone versus placebo in a 2x2 factorial design. The substudy is interested in the evaluation of biospecimens obtained from patients in the colchicine vs placebo group. + Colchicine + Placebo + + + + + Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) trial + will be eligible for participation in this Neutrophil biomarker substudy. These are + patients who present with STEMI. + + + Non-Probability Sample + + + Inclusion Criteria: + + - Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) + trial will be eligible for participation in this Neutrophil biomarker substudy. + + Exclusion Criteria: + + - Use of anti-inflammatory agents (except aspirin) + + - Active infection + + + All + 19 Years + 110 Years + No + + + Binita Shah, MD + Principal Investigator + NYU School of Medicine + + + Fatmira Curovic + 646-501-9648 + fatmira.curovic@nyumc.org + + + Binita Shah, MD + + + + NYU School of Medicine +
+ New York + New York + 10016 + United States +
+
+ Recruiting + + Fatmira Curovic + 646-501-9648 + fatmira.curovic@nyumc.org + + + Binita Shah, MD + +
+ + United States + + September 2019 + March 12, 2019 + March 12, 2019 + March 14, 2019 + September 10, 2019 + September 10, 2019 + September 12, 2019 + + Principal Investigator + NYU Langone Health + Binita Shah + Assistant Professor of Medicine + + + + Myocardial Infarction + ST Elevation Myocardial Infarction + Infarction + + + + Colchicine + + + No + + +
From e0a6c2ef347b693978aa8862fddefe81994a013e Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 20 Jul 2020 18:36:52 -0400 Subject: [PATCH 3/5] refs #537 Show error when unescaping all-caps entity directly --- src/test/java/org/json/junit/XMLTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/json/junit/XMLTest.java b/src/test/java/org/json/junit/XMLTest.java index bc4829922..17fd16776 100644 --- a/src/test/java/org/json/junit/XMLTest.java +++ b/src/test/java/org/json/junit/XMLTest.java @@ -939,4 +939,19 @@ public void testIssue537CaseSensitiveHexEscapeFullFile(){ fail("file writer error: " +e.getMessage()); } } + + /** + * Tests to verify that supported escapes in XML are converted to actual values. + */ + @Test + public void testIssue537CaseSensitiveHexUnEscapeDirect(){ + String origStr = + "Neutrophils.Hypersegmented | Bld-Ser-Plas"; + String expectedStr = + "Neutrophils.Hypersegmented | Bld-Ser-Plas"; + String actualStr = XML.unescape(origStr); + + assertEquals("Case insensitive Entity unescape", expectedStr, actualStr); + } + } \ No newline at end of file From e18f42becc0e87ef067b014dd245b9453a2d7811 Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 20 Jul 2020 18:38:35 -0400 Subject: [PATCH 4/5] fixes #537 corrects case-sensitive entity unescape --- src/main/java/org/json/XMLTokener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/json/XMLTokener.java b/src/main/java/org/json/XMLTokener.java index 0ecdb4f45..3bbd3824b 100644 --- a/src/main/java/org/json/XMLTokener.java +++ b/src/main/java/org/json/XMLTokener.java @@ -167,7 +167,7 @@ static String unescapeEntity(String e) { // if our entity is an encoded unicode point, parse it. if (e.charAt(0) == '#') { int cp; - if (e.charAt(1) == 'x') { + if (e.charAt(1) == 'x' || e.charAt(1) == 'X') { // hex encoded unicode cp = Integer.parseInt(e.substring(2), 16); } else { From c136668f23b459013c959e520baa54f0f1c4fa25 Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 20 Jul 2020 18:58:00 -0400 Subject: [PATCH 5/5] remove new lines from test file text blocks to prevent issues with the parsing compare on different operating systems --- src/test/resources/Issue537.json | 6 +++--- src/test/resources/Issue537.xml | 34 -------------------------------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/src/test/resources/Issue537.json b/src/test/resources/Issue537.json index bf902873b..b3c82feb1 100644 --- a/src/test/resources/Issue537.json +++ b/src/test/resources/Issue537.json @@ -1,19 +1,19 @@ { "clinical_study": { "brief_summary": { - "textblock": "CLEAR SYNERGY is an international multi center 2x2 randomized placebo controlled trial of\r\n colchicine and spironolactone in patients with STEMI. Subjects enrolled in the main CLEAR\r\n SYNERGY trial will be asked to participate in this sub study (n=670) to undergo:\r\n\r\n 1. Evaluation of markers of neutrophil activity at randomization (baseline) and 3 months\r\n follow-up in the colchicine versus placebo groups, and;\r\n\r\n 2. Examination of clinical and genetic factors that determine heterogeneity of treatment\r\n response and distinguish colchicine responders from non- responders.\r\n\r\n Participants undergo a blood draw at baseline and 3 months follow-up as part of the main\r\n trial, and participants who also participate in this sub study will have an additional 2\r\n tablespoons of blood drawn.\r\n\r\n The sub study objectives are to:\r\n\r\n 1. Assess the effect of colchicine on neutrophil activation in response to STEMI.\r\n\r\n 2. Examine clinical and genetic factors that determine heterogeneity of treatment response\r\n anddistinguish colchicine responders from non- responders.\r\n\r\n 3. Explore the derivation of a risk score that includes markers of neutrophil activity and\r\n is associated with adjudicated MACE over 3 years after STEMI, and assess the impact of\r\n colchicine on the relation between this risk score and MACE." + "textblock": "CLEAR SYNERGY is an international multi center 2x2 randomized placebo controlled trial of" }, "brief_title": "CLEAR SYNERGY Neutrophil Substudy", "overall_status": "Recruiting", "eligibility": { "study_pop": { - "textblock": "Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) trial\r\n will be eligible for participation in this Neutrophil biomarker substudy. These are\r\n patients who present with STEMI." + "textblock": "Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) trial" }, "minimum_age": "19 Years", "sampling_method": "Non-Probability Sample", "gender": "All", "criteria": { - "textblock": "Inclusion Criteria:\r\n\r\n - Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9)\r\n trial will be eligible for participation in this Neutrophil biomarker substudy.\r\n\r\n Exclusion Criteria:\r\n\r\n - Use of anti-inflammatory agents (except aspirin)\r\n\r\n - Active infection" + "textblock": "Inclusion Criteria:" }, "healthy_volunteers": "No", "maximum_age": "110 Years" diff --git a/src/test/resources/Issue537.xml b/src/test/resources/Issue537.xml index 9561234a8..bf78f3b39 100644 --- a/src/test/resources/Issue537.xml +++ b/src/test/resources/Issue537.xml @@ -37,29 +37,6 @@ CLEAR SYNERGY is an international multi center 2x2 randomized placebo controlled trial of - colchicine and spironolactone in patients with STEMI. Subjects enrolled in the main CLEAR - SYNERGY trial will be asked to participate in this sub study (n=670) to undergo: - - 1. Evaluation of markers of neutrophil activity at randomization (baseline) and 3 months - follow-up in the colchicine versus placebo groups, and; - - 2. Examination of clinical and genetic factors that determine heterogeneity of treatment - response and distinguish colchicine responders from non- responders. - - Participants undergo a blood draw at baseline and 3 months follow-up as part of the main - trial, and participants who also participate in this sub study will have an additional 2 - tablespoons of blood drawn. - - The sub study objectives are to: - - 1. Assess the effect of colchicine on neutrophil activation in response to STEMI. - - 2. Examine clinical and genetic factors that determine heterogeneity of treatment response - anddistinguish colchicine responders from non- responders. - - 3. Explore the derivation of a risk score that includes markers of neutrophil activity and - is associated with adjudicated MACE over 3 years after STEMI, and assess the impact of - colchicine on the relation between this risk score and MACE. Recruiting @@ -113,23 +90,12 @@ Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) trial - will be eligible for participation in this Neutrophil biomarker substudy. These are - patients who present with STEMI. Non-Probability Sample Inclusion Criteria: - - - Patients who are randomized to the drug RCT portion of the CLEAR SYNERGY (OASIS 9) - trial will be eligible for participation in this Neutrophil biomarker substudy. - - Exclusion Criteria: - - - Use of anti-inflammatory agents (except aspirin) - - - Active infection All