Open Bug 1735545 Opened 4 years ago Updated 3 years ago

Links in json documents with single quotes and parentheses are parsed incorrectly

Categories

(DevTools :: Shared Components, defect, P3)

Firefox 91
defect

Tracking

(Not tracked)

People

(Reporter: jkreft, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0

Steps to reproduce:

go to https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-14152000')

A json doc is returned. Within the returned JSON document is

"@iot.selfLink": "https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-14152000')",

Firefox helpfully parses the response, and makes URLs clickable links. If you click on the link above, however, a tab opens with this following URL:

https://labs.waterdata.usgs.gov/sta/v1.1/Things('USGS-14152000

which 404s, becasue it is missing the closing single quote and paren.

Actual results:

clicking on a URL in a json doc with a single quote and right paren at the end resulted in a link opening with the single quote and right paren truncated.

Expected results:

the full url, including the single quote and paren, should be included in the clickable link.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → JSON Viewer
Product: Core → DevTools

This is a problem in reps, the same happens in the web console.
The single quote is included in the link for me, though. Just the closing parenthesis is missing.
And that seems because of uneatLastUrlCharsRegex

https://searchfox.org/mozilla-central/rev/cc869830d5cb2482a123ed3a63782bfd5dcf74ec/devtools/client/webconsole/utils/messages.js#61-65

// Set of terminators that are likely to have been part of the context rather
// than part of the URL and so should be uneaten. This is '(', ',', ';', plus
// quotes and question end-ing punctuation and the potential permutations with
// parentheses (english-specific).
const uneatLastUrlCharsRegex = /(?:[),;.!?`'"]|[.!?]\)|\)[.!?])$/;

https://searchfox.org/mozilla-central/rev/cc869830d5cb2482a123ed3a63782bfd5dcf74ec/devtools/client/shared/components/reps/reps/string.js#245-252

      // There are some final characters for a URL that are much more likely
      // to have been part of the enclosing text rather than the end of the
      // URL.
      let useUrl = url[2];
      const uneat = uneatLastUrlCharsRegex.exec(useUrl);
      if (uneat) {
        useUrl = useUrl.substring(0, uneat.index);
      }

Maybe it could be refined to not uneat if the whole string is an URL.

Status: UNCONFIRMED → NEW
Component: JSON Viewer → Shared Components
Ever confirmed: true

For the record Chrome is not trying to parse any URL in their DevTools.

Severity: -- → S3
Priority: -- → P3

Still reproducible issue.

Another STRs from bug 1465376

  1. Visit some JSON resource that contains URLs with unencoded spaces as array/object values (example: https://my-json-server.typicode.com/leibrug/json-urls-with-spaces/urls).
  2. Examine response with built-in "JSON preview".
  3. Hover and click an URL with unencoded space.

Honza

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: