Routing InvalidParameterExeception

Created on 13 December 2023, 7 months ago
Updated 12 April 2024, 3 months ago

Problem/Motivation

After running report the /admin/reports/html_tag_usage page showed "The website encountered an unexpected error." Dblog showed PHP Error InvalidParameterExeception: 'Parameter "tag" for route "html_tag_usage.report.inspect" must match "[-a-zA-Z0-9]+" ("box_no" given) to generate a corresponding URL'

Proposed resolution

Looking at https://git.drupalcode.org/project/html_tag_usage/-/blob/1.0.x/html_tag_..., it looks like tag doesn't match pattern of text_format in that text_format allows underscore and tag. If I change the tag to use underscore instead of hyphen, the PHP Error is removed and the HTML tag usage report page can be viewed.

Remaining tasks

* Confirm solution
* Create patch

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand jonathan_hunt

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jonathan_hunt
  • πŸ‡³πŸ‡ΏNew Zealand jonathan_hunt

    I've dug further into the site where this is occurring and the underlying challenge is OCRed text being rendered into a field modelled as `basic_html`. When html_tag_usage analyses the site, it picks up this content and processes it, but in the subsequent report it is is trying to generate routes for html tags that are not valid tags, e.g. <..:><code><..gt:> causing errors in the route generation.

    The root cause is mine to resolve but this module could check whether the "tag" encountered is a..z, A..Z etc. characters before attempting to build a route.

  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    What do we want to do with bad html like this? Seems like it should have another report for it.

    In the code that renders the table, we can check the tags/attributes for invalid options and show a message. But I found it more useful to change the route regex to allow the invalid html so we can see it in the report.

    There is a note in the routing file that the attribute regex is not broad enough, but this issue is for the tag regex. I just added a : to both.

    We can probably use the existing regex to check for valid html and then put the invalid tags in a separate group. We probably don't want to have them in the list at the bottom for copying into text filters, or at least call it out somehow for the dev to consider.

  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    mortona2k β†’ changed the visibility of the branch 1.0.x to hidden.

  • Merge request !33408330: Add colon to tag/attribute β†’ (Open) created by mortona2k
  • Status changed to Needs review 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    The patch fixes the specific error and lets the report load. I created a new issue for a better invalid html report.

  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    mortona2k β†’ changed the visibility of the branch 1.0.x to active.

  • Merge request !43408330: Add colon to tag/attribute β†’ (Open) created by mortona2k
  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    mortona2k β†’ changed the visibility of the branch 1.0.x to hidden.

Production build 0.69.0 2024