iitc-project / ingress-intel-total-conversion

ingress.com/intel total conversion user script with some new features. Should allow easier extension of the intel map.
http://iitc.jonatkins.com/
ISC License
991 stars 552 forks source link

Strip invalid characters from beginning and end of pasted strings #1242

Open retsoksirhc opened 7 years ago

retsoksirhc commented 7 years ago

Had a few people run into this lately, someone copies a drawtools polygon from iitc, the pastes it into a hangout along with descriptive text before or after. Someone else copies the whole text block and pastes it into drawtools, which fails to render because of the extra text.

This PR adds an extra try/catch that activates only if parsing the pasted JSON fails. It strips out anything before and after the first and last [{ }]. What's left is probably what the user actually wanted to paste, and is parsed as JSON.