Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In the pathologic.module there is a fromUri.
fromUri() can throw an exception, we shouldn't die on that.
Proposed resolution
Add a try-catch bloc there.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | catch_exception_in-2602312-2.patch | 734 bytes | edurenye |
|
Comments
Comment #2
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedAdded a try-catch bloc.
Comment #3
Garrett Albright CreditAttribution: Garrett Albright as a volunteer commentedIt looks like the exception is only thrown if parse_url() fails to find a scheme in the URL, but since we're prefixing what we pass in there with "base://", I don't see how that can ever happen. Am I missing something?
Comment #4
BerdirI don't remember what the exact URL was that caused it but I did get an exception on a production site with a lot of weird migrated content so I added this as a way out, seemed better than an aborted page request :)
One way to break it is "base:2015/10/10" because parse_url() parses that incorrectly, that's another problem I had but not with pathologic. But this module calls it with base:// (note that the first is apparently actually the correct way to call it, according to core's usage of base:), then it doesn't break.
Found one way that breaks it:
\Drupal\Core\Url::fromUri('base:///')
but I guess it's possible that all that url validation and parsing above removes leading /, don't remember exactly.I'll try if I can find what pattern broke it exactly.
Comment #5
hey_germanoI ran into this one last night. One of our clients had put some incorrect HTML in a block on their homepage, like this:
<a href="From left to right: Monique Coombs - Maine Coast Fishermen’s Association, Taylor Witkin - Eating with the Ecosystem, and Alan Lovewell - Real Good Fish talk about values">blog post</a>
When I set this up locally to investigate and turned on error reporting, I was able to see the full trace - https://gist.github.com/sarahg/6d53977c446af431777c
The patch in #2 keeps the page from crashing. Thanks!
Comment #6
BerdirYes, it is weird URL's like that.
Comment #7
Garrett Albright CreditAttribution: Garrett Albright as a volunteer commentedComment #8
Garrett Albright CreditAttribution: Garrett Albright as a volunteer commentedCommitted, but not pushed yet (I need to link my local repo from the one on D.o again and I don't have time to do that now), so I'll set back to RTBC.
Comment #10
Garrett Albright CreditAttribution: Garrett Albright as a volunteer commented