realthunder / fcad_pcb

FreeCAD scripts for PCB CAD/CAM
MIT License
126 stars 25 forks source link

sexp parser does not support escaped " #51

Closed easyw closed 2 years ago

easyw commented 2 years ago

related to this ksu issue https://github.com/easyw/kicadStepUpMod/issues/105

If a text field contains an escaped double quote the sexp parser crashed reporting an invalid count of brackets. For example if a footprint contains:

(fp_text user "Active Area 1.3\"" (at -23 -1) (layer "F.Fab")
  (effects (font (size 0.93472 0.93472) (thickness 0.08128)) (justify left bottom))
  (tstamp 60beab46-be82-4200-a5f9-e65c5b3d7176)
)
ithinuel commented 2 years ago

From the test done using regex101, replacing the quoted string matcher (q) with (?P<q>"(\\"|[^"])*") should do the trick. It searches for an escaped quote sequence first and if none it tries for a non-quote character.

easyw commented 2 years ago

@realthunder thanks