Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2020-04-20
04:58
Apply fix for [5e6346a252] and adjust tests. check-in: 32bc8e9f0c user: dgp tags: dgp-utf-explore
2020-04-16
19:33 • Ticket [5e6346a252] Tcl_UtfPrev does not account for rejecting overlong sequence... artifact: fc43f76107 user: jan.nijtmans
17:41 • Closed ticket [5e6346a252]. artifact: 803e04b717 user: dgp
17:41
[5e6346a252] Adapt Tcl_UtfPrev to new Tcl rules that reject overlong sequences. check-in: a315a590f8 user: dgp tags: core-8-5-branch
2020-04-15
22:20 • Ticket [5e6346a252] Tcl_UtfPrev does not account for rejecting overlong sequence... artifact: 98d9ba05e2 user: dgp
22:18 • Ticket [5e6346a252]: 3 changes artifact: 5bb9c2008a user: dgp
19:06 • Ticket [5e6346a252]: 3 changes artifact: 3980a36232 user: jan.nijtmans
17:04 • New ticket [5e6346a252]. artifact: dabcf9db98 user: dgp

Tcl_UtfPrev does not account for rejecting overlong sequences

Closed / Fixed5e6346a252a3e52f764f6a58e7c52cfc72b4a061Created 7 years agoUpdated 7 years ago
Descriptionplain2020-04-15 17:04:48
Since Tcl started rejecting overlong UTF-8 sequences [67aa9a2070], Tcl_UtfPrev is
out of sync with the new rules for what Tcl accepts.

test utf-7.26 {Tcl_UtfPrev -- overlong sequence}  testutfprev {
    testutfprev A\xE0\x80\x80
} 3

This fails, returning the wrong value 1 instead.
Referenced by2
jan.nijtmansplain2020-04-15 19:06:24
I'm guilty as charged ....  :-).    This behavior is backported from 8.7, and - since this handles an invalid byte sequence - it can only be triggered by carefully crafted native code, not from a pure Tcl script.

That said, Tcl_UtfPrev() and Tcl_UtfNext() don't behave well in all situations, mainly when invalid byte-sequences are involved. You are showing that with a lot of test-cases. That's great, and something I appreciate you are doing.

Does the [bug-31aa44375d] branch solve this for you?  I think not for 100%, because some of the fixes you did in a branch derived from 8.5 are not ported forward yet. Since Tcl 8.6.7 is 2 1/2 years old, and no-one filed a bug-report on this, I don't understand your "Important", but so be it.

If you are satisfied with the [bug-31aa44375d] branch, then feel free to merge it to core-8-6-branch. I won't resist. Since I didn't file a TIP for 8.6, I don't have enough ground below me to stand on.
dgpplain2020-04-15 22:18:14
Given the choices of the selector "Important" is the middle ground.

I don't want to pick "Cosmetic" or "Minor". It's a real bug to be fixed.

I don't want to sound the alarms of "Critical" or "Severe". It's not either of those.

An option of "Normal" would be about right.
dgpplain2020-04-15 22:20:03
I am still working my way forward to decide what's best to do on the 8.6 branch.

Having these test mark what changed and when and why helps me organize
and demonstrate my thoughts. I appreciate the assists in merging.
dgpplain2020-04-16 17:41:37
Fixed in 8.5.
jan.nijtmansplain2020-04-16 19:33:41
Strange .... This ticket says:  Version: 8.6.7+, how can it be fixed in 8.5  ????  So, actually it was a much more ancient present problem....  :-)

There's a lot of confusion about how Tcl_UtfPrev/Tcl_UtfNext should be have. For valid UTF-8 sequences, it's clear what should be done. For invalid UTF-8 sequences: who cares, since they only can be inserted using (mal-behaving) extensions or the 'identity' encoding. I see no problem merging this forward.
Log in (anonymous is fine) to add a comment.