|
[HepData-svn] r1925 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgTue Feb 2 15:38:02 GMT 2016
Author: watt Date: Tue Feb 2 15:38:02 2016 New Revision: 1925 Log: YAML formatter: escape single-quote characters in a few more places 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 Mon Feb 1 14:38:37 2016 (r1924) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Tue Feb 2 15:38:02 2016 (r1925) @@ -185,10 +185,8 @@ s.append("name: 'Table "+ds.getId()+"'\n"); for (String ct : ds.getComments()){ - if(ct.startsWith("Location:")) { - location = ct.replaceFirst("Location:","").replaceAll(" ",""); - // s.append("label: "+ct.replaceFirst("Location:","Data from")+" from: "+p.getTitle()+"\n"); - s.append("label: '"+ct.replaceFirst("Location:","Data from")+"'\n"); + if(ct.startsWith("Location:")) { + s.append("label: '"+ct.replaceFirst("Location:","Data from").replaceAll("'","''")+"'\n"); } } @@ -548,14 +546,14 @@ if(error.getPlus()==0.0){ if(first) { s.append(s4+"qualifiers:\n"); } first=false; - s.append(s4+sp+"{name: 'SYS', value: '"+error.getComment()+"'}\n"); + s.append(s4+sp+"{name: 'SYS', value: '"+error.getComment().replaceAll("'","''")+"'}\n"); } } for(Uncertainty error : yax.getErrors()){ if(error.getPlus()==0.0){ if(first) { s.append(s4+"qualifiers:\n"); } first=false; - s.append(s4+sp+"{name: 'SYS', value: '"+error.getComment()+"'}\n"); + s.append(s4+sp+"{name: 'SYS', value: '"+error.getComment().replaceAll("'","''")+"'}\n"); } } @@ -647,7 +645,7 @@ else if(error.getSourceType()==ErrorSource.SYS) s.append(", label: 'sys"); else if(error.getSourceType()==ErrorSource.TOTAL) s.append(", label: 'total"); if (error.getSourceType()==ErrorSource.STAT || error.getSourceType()==ErrorSource.SYS || error.getSourceType()==ErrorSource.TOTAL) { - if(!error.getComment().equals("")) s.append(","+error.getComment()); + if(!error.getComment().equals("")) s.append(","+error.getComment().replaceAll("'","''")); s.append("'"); } s.append("}\n");
More information about the HepData-svn mailing list |