Page MenuHomePhabricator

Encode sharing portion of reading lists in URL
Closed, DuplicatePublic



The Android team is working on allowing reading lists to be shared (see epic for details). In order to achieve this the sharing portion needs to be encoded in a URL.

Must Haves (Technical Details)
User Stories
  • As a Wikipedia Android app user and student in Morocco, I want to export my reading lists, so that I can use it at the Mohammed V University school library
  • As a Wikipedia Android app user in Ghana, I want to share my reading list with a family member in the US that has an iOS device, so they can read the articles I've saved about Accra ahead of their trip home in December.
  • As a Wikipedia Android app user organizer in South Asia, I want to share reading list via Whatsapp after an event, so people that have attended know which articles are in need of contributions

Event Timeline

JTannerWMF triaged this task as Medium priority.Aug 31 2022, 9:56 PM
JTannerWMF created this task.
JTannerWMF added a subscriber: Dbrant.

@Dbrant to provide technical instructions in task

I'm coming from a position of not knowing anything at all about how much data you need to share, so I want to highlight some limitations to encoding things into the URL that might turn out to not be relevant.

It sounds like you want to share a blob of JSON which contains some amount of data about a list-of-pages. At a minimum this would presumably be an array of page IDs, but it might also be page titles and perhaps metadata (time-saved, notes, etc?). I don't have any idea whether you limit on the allowed size of these shared lists -- if you don't then even the most minimal representation is going to run into issues eventually.

The major issue is that browsers and web servers impose some limits on how long URLs can be. Internet Explorer is the worst, since it's around 2k characters -- but if we don't care about these links working in IE then we get a bit more room. I've seen various claims for Edge over the years, and it certainly spent a few years hovering around 4k but might have been increased since then. Most of the other browsers are well over this, at least 64k but sometimes more.

The next big hurdle is: wikipedia uses Apache as its application webserver (I believe), and Apache's default URL length limit is 8177 characters. You'd need to ask someone in ops whether we override the default LimitRequestLine, but if not then that's your big limit on shared list size. (You could get around this by having the JSON in the fragment since that's not sent to the server, but that would completely lock you in to writing a client-side javascript single-page-app to display the list.)

It's worth considering, as well, that even a 2k URL is going to be really awkward to share. To give you a fun example, here's one:

That's 2kb of JSON stuck on the end of a wiki URL, sharing 235 pageid-like numbers. 🤩

Thanks, @DLynch
The idea we're exploring so far is to pass this encoded URL into our URL shortener (, and the shortened URL will be what's shared.
We're aware that the URL shortener itself imposes a limit of ~1500 characters (smaller than all the other browser-side and Apache-side constraints you listed), and we're fine if it means that the maximum number of page IDs we can share is on the order of 100.

There is some further trickery we can explore to squeeze more data into the URL fragment, e.g. gzipped json + base64, packed binary structure + base64, etc. But in any case, a limit on the number of shareable articles is something we've accepted.

The structure will basically be:

  title: "My list",
  description: "Description of list",
  pages: [
    { "en": 123456 },
    { "en": 345678 },
    { "de": 789243 },
    { "ru": 912378 },

(note that the page IDs can come from arbitrary language wikis, not just a single wiki.)

I suppose it's a little bit silly to wind up basically using the URL shortener as blind JSON-blob storage rather than making something more focused for the task, but I can see how project constraints might lead you to it.

As I said in the meeting, this is not good idea. As David said, url shortener is not a json blob storage. You even have the instrumentation and the infra, you can add a column to the table to make a reading list public and share its id instead.

I can totally see how the idea of doing it this way raises an eyebrow, but like you say, this is a consequence of our project constraints.

The big constraint is that the reading lists in a user's app are not necessarily synced to the server (the user doesn't need to be logged in at all, and even if they are, syncing of reading lists is optional), so the reading lists effectively exist on the client only, and therefore the only way to "share" them is to encode them into a literal payload. We're certainly open to other ideas for how this could be done.

If we suppose that we start requiring the user to log in and sync their lists before sharing, this would certainly allow us to share the list by its id by marking the list as public. However, that would open an even larger can of worms with regard to moderation and patrolling of lists.

However, that would open an even larger can of worms with regard to moderation and patrolling of lists.

I don't agree with this -- I think the moderation burden is the same either way. Both options involve a person visiting a Wikipedia-branded page and seeing (as I understand it) the user-provided list title and description. If someone shares something full of racial slurs or death threats, we're not going to get away with saying "technically that's not stored in our database". (The drawback here, of course, is that it's almost impossible for us to actually moderate things shared in the JSON-blob method...)

For that matter, even ignoring the title and description which we could run through content blacklists, I'm confident I could construct something horrifically offensive purely with a list of articles...

Hi @DLynch thank you for your product related concerns. They will be taken into consideration as we discuss it with Adam and Josh on Tuesday. I hope you have confidence that we are evaluating the risks of the project, especially mitigating things like racial slurs, something that can be quite triggering as you can imagine. When we settle on an approach I will be sure to ping you on the project page since you are an eagerly interested party.

@Ladsgroup , happy to have an additional circle up regarding using the URL shortner since it seems the initial conversations we had with you and Ed have gotten lost in translation and we should probably revisit what was discussed.