hypothesis / client

The Hypothesis web-based annotation client.
Other
642 stars 197 forks source link

Corrupts textarea field if its contents are annotated #5376

Open Chealer opened 7 years ago

Chealer commented 7 years ago

I was demonstrating Hypothes.is to a colleague using the Tiki Wiki CMS Groupware web application engine. I annotated a word part of the default wiki page, then went on to modify the wiki page, to show that Hypothes.is deals with changes to the annotated text.

To my great surprise, in the textarea input field where one modifies the page's content, the annotated word disappeared. Saving the page did remove the annotated word from the page's content.

This happened with Tiki versions 15, 16 and 17, using Google Chrome versions 60 and 62 with extension versions 1.48.0.0 and 1.50.0.0, on 2 Windows machines. This reproduced whether the page's content was French or English. I however only reproduced this on local Tiki installations, except for a demonstration instance. I created a page called "HomePage2" in that instance using the default contents of Tiki's homepage.

To reproduce:

  1. Create or edit a wiki page to contain the contents of the default homepage: hypothesis corruption before
  2. Activate the Hypothes.is extension
  3. Select the word "configuring"
  4. Submit any comment: hypothesis corruption during annotation
  5. Click Edit to go to tiki-editpage.php?page=HomePage: hypothesis corruption during edit You will notice the word "configuring" disappearing during page load. If you save, you should see: hypothesis corruption after If you then go to the history, you can confirm the corruption comparing versions: hypothesis corruption diff

The HTTP credentials to enter the demonstration instance are "show"/"show". The password for user admin is "12345".

I did not investigate why the word is removed.

robertknight commented 7 years ago

From a quick look, I think this is what is happening:

  1. The view page has the URL http://jmorris-11758-6403.show.tikiwiki.org/tiki-index.php?page=HomePage2 and includes a <link> tag pointing to the edit page: <link rel="alternate" type="application/x-wiki" title="Edit this page!" href="tiki-editpage.php?page=HomePage2">.
  2. My guess is that (1) creates a URL equivalence relationship in Hypothesis such that the same set of annotations are presented on both pages.
  3. When going to the edit page, Hypothesis fetches annotations that were made on the view/index page and tries to locate them. It will find the matching content inside the <textarea>
  4. Hypothesis currently highlights text by extracting the matching text and then re-inserting it inside a <hypothesis-highlight> node. AFAIK a <textarea> tag cannot have children and so this process doesn't work properly, resulting in the matching text just being removed.

The current highlighting mechanism cannot work inside a <texarea> so I suggest there are a couple of things we should do here:

  1. Revisit whether we want to create URL equivalences when we discover <link rel="alternate" ...> tags in the page.
  2. Change how we handle anchoring or highlighting if the matching content occurs inside a node that doesn't support child elements.
Chealer commented 6 years ago

Many thanks @robertknight

Your 2 first quick look points must be right - well spotted. I don't know Hypothesis enough to tell but I guess 3 and 4 are correct too.

As for your suggestions, I am not sure 1 is needed, but 2 must be.