df-xmldecode-patch #1
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "df/tvdb:df-xmldecode-patch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
theTVDB.com started sending single quotes in XML encoded as
'
rather than"
as observed in this thread.One fix was to
webif/lib/xml.class
; however this program replicates the decoding process in the Jim class (which is a lot slower) and needs to be fixed as well.The patch uses
sscanf()
to detect and decode numerically coded XML character entities within the original framework of theunescape()
function.Modified compilation options:
-std=c99
for thehh
format size prefix-D_XOPEN_SOURCE=700
for correct declaration ofstrdup()
in the on-box build environment.WIP: df-xmldecode-patchto df-xmldecode-patchApparently does the job but the build needs to be tested in the usual environment.
@ -61,0 +58,4 @@
/* sscanf -> 1: the code was read; ll>0: ';' came next */
if ((1 == sscanf( p, "&#%hhu;%n", &icode, &ll) ||
1 == sscanf( p, "&#%*[xX]%hhx;%n", &icode, &ll)) &&
ll > 0) {
sscanf()
will return 2 if two input items were converted, won't it?You'd think so, but free30 and I have both run the version built from that code, so apparently not, and I am more confident of that based on the following.
POSIX (admittedly a racily anachronistic 2017 version says):
"Upon successful completion, these functions shall return the number of
successfully matched and assigned input items;"
Arguably, as
%n
doesn't involve any matching, it doesn't count towards the result.Also, as
%*[xX]
doesn't involve any assigning, it also doesn't count.In the library source I see this (
libc/stdio/_scanf.c
l.1331ff):So MJN3 decided that %n didn't cause
zero_conversions
to be cleared, which is done for formats like %s, %d.Also, the 0/1 flag (
unsigned char store
) member that is cleared/set according to whether the format contains*
to suppress assignment is used to increment the return count.