roysmith / spi-tools

8 stars 3 forks source link

Date header not parsed with socklist template #212

Closed roysmith closed 2 years ago

roysmith commented 2 years ago

Wikipedia:Sockpuppet investigations/Tounom

23 February 2022 is missing.

TamzinHadasa commented 2 years ago

@roysmith I will look closer at this shortly, but just off the bat, I don't thing mwparserfromhell distinguishes between {{foo|bar}} and {{foo|1=bar}}, so I'm wondering why this would be an issue. But again, will look closer soon.

roysmith commented 2 years ago

As far as I can tell, mwparserfromhell doesn't provide a way to iterate over just the positional parameters; you need to look at the parameter name and see if its an integer. Maybe I'm just missing something in the API?

roysmith commented 2 years ago

Fixed in 664371fea0c1dc281c1dbdcac0d1632875c3d38e

TamzinHadasa commented 2 years ago

@roysmith param.name will only be an empty string if someone passes {{foo|=bar}}. Meanwhile, for a positional param, param.name will always be an all-digits string, and that's true whether or not n= is made explicit. For instance:

>>> text = "{{foo|bar|2=baz}}"
>>> template = mwparserfromhell.parse(text).filter_templates()[0]
>>> [i.name for i in template.params]
['1', '2']

So to see if a param is positional, I'd think all you need to do is check whether param.name.isdigit().

roysmith commented 2 years ago

I had forgotten about isdigit(). What I did works, but isdigit() would have made it simpler.