Open nicolas-raoul opened 1 year ago
Hi @nicolas-raoul, while testing the app, I found that this issue exists only for some images on the app. While I have not been able to figure out the reason for this selective behaviour as of now, I found a fix on stackoverflow: https://stackoverflow.com/questions/240546/remove-html-tags-from-a-string#:~:text=replace(%22%26%22%2C,line%20breaks%20String%20clean%20%3D%20Jsoup. EDIT: I have personally tried the replaceAll() method and it worked well for the image which had tags in its fallback description earlier. I can try the other way too if you feel stripping the tags off the fallback description string is an appropriate fix for this issue.
Seeing the image's page https://commons.wikimedia.org/wiki/File:SANY_R285R_excavator_in_Thailand.jpg I see that the caption does not contain any tag. So I would suggest trying to:
Yes, the caption does not contain any tag. But hovering over the edit icon on the image's page shows the same name as found in the tag above:
title="Edit this at Structured Data on Commons
.
I think that since most of the other images do not have this icon, they don't have the anchor tag too.
Should I check if it is reading the image's description instead of its caption?
Yes, finding the API call and what part of the API response we use would be a great start :-)
Please post the API call URL when you find it. Thanks!
Thank you for clarifying. Now that I understand the issue better, I will be able to find the cause easily.
I tried looking for the API call and found that the app currently makes use of the following API call URL to fetch the metadata of the image:
This is what I found about the prop extmetadata in the official API documentation:
Since the results are HTML formatted, I tried looking for an alternate call that returns only the image description or the image details in an appropriate format, directly or indirectly, but couldn't find anything. However, I found this action which converts HTML into wikitext and is more reliable than stripping the string off to remove the tags:
@RitikaPahwa4444 I am getting an error when clicking the URL you posted. One thing, I guess the API call made by the app should be to the Commons server rather than to Wikipedia?
I'm sorry, I should have mentioned that the API call depends on the query at runtime and fetches results accordingly. It needs three parameters: "gsrsearch", "gsrlimit" and "gsroffset". This is the reason why the error code shows: "The \"gsrsearch\" parameter must be set."
.
I have modified the URL a bit with some sample data so that the results are visible:
https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&generator=search&gsrsearch="SANY R285R excavator in Thailand.jpg"&gsrwhat=text&gsrnamespace=6&prop=imageinfo|coordinates&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl
EDIT: I think I got confused as the directory name for the data client was org/wikipedia and both Commons and Wikipedia API have a call for image info. I have modified the API call URL and used the required file for gsrsearch.
I'm also experiencing this problem on commons app SOMETIMES in latest f-droid 4.1.0
release (on Android 10).
In most cases it works OK (like 00:00-00:13 in this video) where clicking on wikitext button of uploaded image produces correct text like [[File:Nikola Šubić Zrinski Square.jpg|thumb|Nikola Šubić Zrinski Square (square)]]
(https://commons.wikimedia.org/wiki/File:Nikola_%C5%A0ubi%C4%87_Zrinski_Square.jpg)
but in some cases (like 00:16-00:25 in this video) it breaks, and produces invalid text like [[File:Statue of Nikola Tesla, Zagreb.jpg|thumb|statue of Nikola Tesla, Zagreb <span class="mw-valign-text-top" typeof="mw:File/Frameless"><a href="//commons.wikimedia.org/wiki/File:Statue_of _Nikola_Tesla,_Zagreb.jpg#ooui-php-4" title="Edit this at Structured Data on Commons"><img alt="Edit this at Structured Data on Commons" src="https://upload.wikimedia.org/wikipedia/commons/th umb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/10px-OOjs_UI_icon_edit-ltr-progressive.svg.png" decoding="async" width="10" height="10" class="mw-file-element" srcset="https://upload.wikimedia .org/wikipedia/commons/thumb/8/8a/OOjs_UI_icon_edit-ltr-progressive.svg/15px-OOjs_UI_icon_edit-ltr-progressive.svg.png 1.5x, https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/OOjs_UI_ icon_edit-ltr-progressive.svg/20px-OOjs_UI_icon_edit-ltr-progressive.svg.png 2x" data-file-width="20" data-file-height="20"></a></span>]]
(https://commons.wikimedia.org/wiki/File:Statue_of_Nikola_Tesla,_Zagreb.jpg)
Video:
This is the log a day after when I just do the copy/paste with results in incorrect value: CommonsAppLogs.zip
And this is a log that seems to contain (among other things) original upload of that problematic File:Statue of Nikola Tesla, Zagreb.jpg
: CommonsAppLogs.zip
Does that help track this down?
I don't think the anchor tag should be there?