ocsigen / ocsigen/tyxml

Tyxml should not accept a form as an indirect descendant of another form

Open
#149 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug html & svg standard typing
Dominant language
OCaml
Stars
179
Forks
63
Avg merge
5h
Merged PRs (30d)
22

Description

Tyxml's phantom-type trickery prevents a form from being the child of another form:

# Html5.M.(form [form []]);;
Error: This expression has type ([> Html5_types.form ] as 'a) Html5.M.elt
       but an expression was expected of type
         ([< Html5_types.form_content_fun ] as 'b) Html5.M.elt

However, it does not prevent a form from being the grandchild of another form:

# Html5.M.(form [div [form []]]);;
- : [> Html5_types.form ] Html5.M.elt = <abstr>

There seems to be at least one example in the wild where this loophole caused problems: depending on the content-type, browsers will either reluctantly accept nested forms or reject them by messing with the parse tree.

This problem is probably difficult to fix without major changes to Tyxml's phantom-type trickery, but should perhaps be at least documented, as it's damn hard to diagnose when things go wrong.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two Html5.M examples from the issue and compare the accepted grandchild case with the rejected direct child case. Trace Tyxml's phantom-type definitions to determine whether indirect nesting can be prevented without the major changes mentioned; otherwise, document the limitation and its browser consequences clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.