File tree Expand file tree Collapse file tree
lib/private/Collaboration/Reference Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,6 +104,22 @@ private function fetchReference(Reference $reference): void {
104104 }
105105
106106 $ client = $ this ->clientService ->newClient ();
107+ try {
108+ $ headResponse = $ client ->head ($ reference ->getId (), [ 'timeout ' => 10 ]);
109+ } catch (\Exception $ e ) {
110+ $ this ->logger ->debug ('Failed to perform HEAD request to get target metadata ' , ['exception ' => $ e ]);
111+ return ;
112+ }
113+ $ linkContentLength = $ headResponse ->getHeader ('Content-Length ' );
114+ if (is_numeric ($ linkContentLength ) && (int ) $ linkContentLength > 5 * 1024 * 1024 ) {
115+ $ this ->logger ->debug ('Skip resolving links pointing to content length > 5 MB ' );
116+ return ;
117+ }
118+ $ linkContentType = $ headResponse ->getHeader ('Content-Type ' );
119+ if ($ linkContentType !== 'text/html ' ) {
120+ $ this ->logger ->debug ('Skip resolving links pointing to content type that is not "text/html" ' );
121+ return ;
122+ }
107123 try {
108124 $ response = $ client ->get ($ reference ->getId (), [ 'timeout ' => 10 ]);
109125 } catch (\Exception $ e ) {
You can’t perform that action at this time.
0 commit comments