code-embed icon indicating copy to clipboard operation
code-embed copied to clipboard

Page load hungs when using URL embeding

Open galmos opened this issue 3 years ago • 2 comments

I'm using version 2.3.4 of the plugin and the page I'm trying to load hangs when using URL embedding codes.

Just loading an external page with:

{{https://www.example.com/page}}

But it does not work. I've tried to change these tags to check if there is some kind of conflict with the theme used but no way.

The theme I'm using right now is The 7

Thank you very much

galmos avatar Jan 26 '22 13:01 galmos

I've found what's wrong about this issue:

First of all, there is an infinite loop in the ce_quick_replace when the requested url gives an error. When there is an error inside the ce_get_file function, the following line always gives the same startpos, because there is no offset and there hasn't been any replacement on $content.

$start_pos = strpos( $content, $options['opening_ident'] . $search, 0 );

This happens because there is an error reading the url to request, in this line:

$url = substr( $content, $start_pos + 1, $end_pos - $start_pos - 1 );

The line should be as follows: $url = substr( $content, $start_pos + strlen($options['opening_ident']), $end_pos - ($start_pos + strlen($options['opening_ident'])) );

With those changes the problem is fixed.

Will try to make a PR in case anyone is interested

galmos avatar Jan 27 '22 09:01 galmos

Thanks @galmos - I'll get the change implemented.

dartiss avatar Jan 27 '22 10:01 dartiss

Fixed in 2.5

dartiss avatar Sep 29 '24 17:09 dartiss