You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need to take care to get the MALFORMED_LAT, MALFORMED_LON & LABEL_TOO_LONG datachecks right. Data inserted into datacheckErrors.label1 and datacheckErrors.value must be neither:
overlength
truncated in the middle of a multi-byte character
It's very rare that this would actually happen, but gotta do it right.
LABEL_TOO_LONG cases should be ignored, similar to the malformed URL cases. Rationale: To not ignore it means putting it in the DB, which means truncating the label to something of legal length. This truncated label could then end up in a .list file, and thus pointsinuse.log. Copying from there and pasting into wptedit would not flag the label as in-use, because the full label from the .wpt code doesn't match the truncated one from pointsinuse.log. It could too easily lead us to breaking .list files.
# some constants to get this code to work standalone in the python3 terminallabel="12345678901234567890ññ3456789012345678901234567890"# pick one#label = "12345678901234567890ññ345678901234567890123456789" # pick oneclassDBFieldLength:
label=26dcErrValue=32############################################################################slicepoint=DBFieldLength.label-3whilelen(label[:slicepoint].encode('utf-8')) >DBFieldLength.label-3:
slicepoint-=1print('"'+label[:slicepoint]+'..." goes into [datacheckErrors.label1]')
excess="..."+label[slicepoint:]
print(excess)
iflen(excess.encode('utf-8')) >DBFieldLength.dcErrValue:
slicepoint=DBFieldLength.dcErrValue-3whilelen(excess[:slicepoint].encode('utf-8')) >DBFieldLength.dcErrValue-3:
slicepoint-=1excess=excess[:slicepoint]+"..."print(excess)
...all this because there's no way to take a string and slice it at an arbitrary byte boundary. I can convert to a bytearray, but if that's sliced mid-character, I can't convert it back to a string. And I can write strings xor bytearrays to a file, but not a mix of both, it appears. What a pain in the...wow.
C++, OTOH? On further thought, cutting the strings mid-character matters less. These points will be ignored & not make it into the HB or .lists, just shown on datacheck.php. Since the point doesn't make it as far as the LABEL_INVALID_CHAR datacheck, a � will give a bit more of an indication that, like with any multi-byte character, we have an invalid character.
So I'll just handle Python & C++ differently, whatever gets the job done most conveniently in each language.
Python: Points are ignored, but the DatacheckEntrys don't make it to the datacheckerrors list. Edt: They did, only flagged for a completely different route. Wow, Python. Variables. Scope.
C++: Crap! Apparently MySQL 8.0 doesn't like the C3 byte when it's not part of a UTF-8 char. I'll keep it simple & just cut the string where I cut it, removing everything >7F from the end of datacheckErrors.label1 & the beginning of datacheckErrors.value.
Activity
yakra commentedon Apr 4, 2020
LABEL_TOO_LONG
...all this because there's no way to take a string and slice it at an arbitrary byte boundary. I can convert to a bytearray, but if that's sliced mid-character, I can't convert it back to a string. And I can write strings xor bytearrays to a file, but not a mix of both, it appears. What a pain in the...wow.
C++, OTOH? On further thought, cutting the strings mid-character matters less. These points will be ignored & not make it into the HB or .lists, just shown on datacheck.php. Since the point doesn't make it as far as the LABEL_INVALID_CHAR datacheck, a � will give a bit more of an indication that, like with any multi-byte character, we have an invalid character.
So I'll just handle Python & C++ differently, whatever gets the job done most conveniently in each language.
yakra commentedon Apr 5, 2020
Replacing waypoint labels in me.me188.wpt with
DatacheckEntrys don't make it to thedatacheckerrorslist. Edt: They did, only flagged for a completely different route. Wow, Python. Variables. Scope.C3byte when it's not part of a UTF-8 char. I'll keep it simple & just cut the string where I cut it, removing everything >7Ffrom the end ofdatacheckErrors.label1& the beginning ofdatacheckErrors.value.yakra commentedon Apr 9, 2020
Python malformed URL checks still don't account for multi-byte chars driving the byte count too high.
Edit: Ack, but does it matter though?
Right now siteupdate.py counts multi-byte chars toward the total char counts, without splitting them.
Will go no-build pending a cleanup per #299.