Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom URLs in galleries without schema creates relative links #747

Closed
4 tasks done
mmtr opened this issue Aug 17, 2019 · 7 comments
Closed
4 tasks done

Custom URLs in galleries without schema creates relative links #747

mmtr opened this issue Aug 17, 2019 · 7 comments

Comments

@mmtr
Copy link
Contributor

mmtr commented Aug 17, 2019

Describe the bug
The custom URLs entered in the gallery images are not being sanitized / validated, so entering an URL without the schema (http(s)://) will create a relative URL.

To Reproduce

  1. Insert a gallery block such as Masonry.
  2. Add some images to the gallery.
  3. Under "Link Settings" in the Block Settings, choose Custom URL.
  4. Enter an address without http:// or https:// (i.e. godaddy.com).
  5. Publish the page/post.
  6. Visit the published post/page.

Expected behavior
To be taken to the external website upon clicking the gallery image, but instead you're taken to an internal path (i.e. example.com/2019/08/17/my-post/godaddy.com).

Isolating the problem:

  • This bug happens with no other plugins activated
  • This bug happens with a default WordPress theme active
  • This bug happens without the Gutenberg plugin active
  • I can reproduce this bug consistently using the steps above

WordPress Version
5.2

Gutenberg Version
6.3.0

@kwight
Copy link
Contributor

kwight commented Aug 19, 2019

entering an URL without the schema (http(s)://) will create a relative URL

Hm, I'm not sure I'd consider this a bug; dot characters are valid in URL paths (think of versioned API URLs), so the presence of a dot doesn't mean we aren't referring to a relative path. Maybe the "fix" is a description in the Link Settings section specifying that the schema needs to be explicit for links to other domains?

@mmtr
Copy link
Contributor Author

mmtr commented Aug 20, 2019

the presence of a dot doesn't mean we aren't referring to a relative path.

Yeah, I'm not suggesting that. I only think a user will expect an absolute URL in most of the scenarios. Note that absolute URLs will work for linking to internal pages too (the input allows to search for any blog page/post and it'll use the absolute URL). So maybe it'll be simpler (from a user perspective) if the plugin assumes all the URLs are absolute and append the schema when not entered.

@richtabor
Copy link
Contributor

Appreciate the report. Does the core Gallery Block behave the same way?

@mmtr
Copy link
Contributor Author

mmtr commented Aug 23, 2019

@richtabor AFAIK the core Gallery Block doesn't allow to link images to custom URLs.

@mmtr
Copy link
Contributor Author

mmtr commented Aug 23, 2019

🤔 Actually, the core image block does allow it and has the same behavior. Reported there as well: WordPress/gutenberg#17155

Are the CoBlocks galleries using the same tool for linking the images?

@richtabor
Copy link
Contributor

🤔 Actually, the core image block does allow it and has the same behavior. Reported there as well: WordPress/gutenberg#17155

Are the CoBlocks galleries using the same tool for linking the images?

Ahhhh I see now. We are for the most part, but I've added the custom URL functionality as that doesn't exist in core.

@jrtashjian
Copy link
Member

@mmtr Thanks for submitting the issue. However this does seem to be a behavior of core. I see you've already reported the issue to core so I'd like to close this one in favor of that one. The effort is best spent there and inherited by everyone.

For reference, closing this in favor of WordPress/gutenberg#17155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants