|
[HepData-svn] r1928 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Feb 12 18:08:19 GMT 2016
Author: watt Date: Fri Feb 12 18:08:19 2016 New Revision: 1928 Log: YAML formatter: escape single-quote characters in keywords Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Tue Feb 9 14:27:37 2016 (r1927) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Fri Feb 12 18:08:19 2016 (r1928) @@ -210,7 +210,7 @@ s.append(sp+"{name: reactions, values: ["); int nr=0; for (String dsreac : ds.getDsReactions()){ - s.append("'"+dsreac+"'"); + s.append("'"+dsreac.replaceAll("'","''")+"'"); if(++nr==ds.getDsReactions().size()){s.append("]}\n"); } else {s.append(", ");} } @@ -219,7 +219,7 @@ s.append(sp+"{name: observables, values: ["); int no=0; for (String dsobs : ds.getDsObservables()){ - s.append("'"+dsobs+"'"); + s.append("'"+dsobs.replaceAll("'","''")+"'"); if(++no==ds.getDsObservables().size()){s.append("]}\n"); } else {s.append(", ");} } @@ -228,7 +228,7 @@ s.append(sp+"{name: plabs, values: ["); int np=0; for (String dsplab : ds.getDsPlabs()){ - s.append("'"+dsplab+"'"); + s.append("'"+dsplab.replaceAll("'","''")+"'"); if(++np==ds.getDsPlabs().size()){s.append("]}\n"); } else {s.append(", ");} } @@ -237,13 +237,13 @@ s.append(sp+"{name: phrases, values: ["); int np=0; for (String pkey : p.getKeywords()){ - s.append("'"+pkey+"'"); + s.append("'"+pkey.replaceAll("'","''")+"'"); if (++np!=p.getKeywords().size() || ds.getDsKeywords().size() > 0) { s.append(", "); } } int nd=0; for (String dskey : ds.getDsKeywords()){ - s.append("'"+dskey+"'"); + s.append("'"+dskey.replaceAll("'","''")+"'"); if (++nd!=ds.getDsKeywords().size()) { s.append(", "); } }
More information about the HepData-svn mailing list |