AuburnACM / auacm

The Auburn ACM Website
Apache License 2.0
15 stars 3 forks source link

Fix crashes from string encoding and database column limit #56

Closed WilliamHester closed 8 years ago

WilliamHester commented 8 years ago

Okay, so I was trying to submit a problem and I got this error. Eventually, I boiled it down to our casting of request.form['cases'] to a string type. After removing the cast, I ran into a separate yet related issue where the column only allowed for sample cases that were 255 characters or less, which was not enough for some of the old-style problems, since, technically, there's only one test case.

BrandonLMorris commented 8 years ago

Is this a result of PDF's weird encoding of whitespace? Were you trying to directly copy/paste into the text box?

I looked it up, the issue is a non-breaking space (unicode 160). The real issue is that it's Python 2, where not all strings are Unicode. The error wouldn't have happened in Python 3. loads() accepts a sting or unicode object (see docs) so that's why removing the cast works.

That being said, I agree about upping the 255 character limit. I thought it might be appropriate, I should have seen that it wasn't.

"Premature optimization is the root of all evil"