If our host matched in File lookup, it could throw exceptions on Router->map
This commit is contained in:
parent
d179afa303
commit
a24c6fdb39
@ -113,6 +113,7 @@ class File extends Managed_DataObject
|
|||||||
if (isset($u['host']) && $u['host'] === common_config('site', 'server')) {
|
if (isset($u['host']) && $u['host'] === common_config('site', 'server')) {
|
||||||
$r = Router::get();
|
$r = Router::get();
|
||||||
// Skip the / in the beginning or $r->map won't match
|
// Skip the / in the beginning or $r->map won't match
|
||||||
|
try {
|
||||||
$args = $r->map(mb_substr($u['path'], 1));
|
$args = $r->map(mb_substr($u['path'], 1));
|
||||||
if ($args['action'] === 'attachment') {
|
if ($args['action'] === 'attachment') {
|
||||||
try {
|
try {
|
||||||
@ -125,6 +126,18 @@ class File extends Managed_DataObject
|
|||||||
// apparently this link goes to us, but is _not_ an existing attachment (File) ID?
|
// apparently this link goes to us, but is _not_ an existing attachment (File) ID?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Some other exception was thrown from $r->map, likely a
|
||||||
|
// ClientException (404) because of some malformed link to
|
||||||
|
// our own instance. It's still a valid URL however, so we
|
||||||
|
// won't abort anything... I noticed this when linking:
|
||||||
|
// https://social.umeahackerspace.se/mmn/foaf' (notice the
|
||||||
|
// apostrophe in the end, making it unrecognizable for our
|
||||||
|
// URL routing.
|
||||||
|
// That specific issue (the apostrophe being part of a link
|
||||||
|
// is something that may or may not have been fixed since,
|
||||||
|
// in lib/util.php in common_replace_urls_callback().
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = new File;
|
$file = new File;
|
||||||
|
Loading…
Reference in New Issue
Block a user