mystream
Forum Replies Created
-
Forum: Plugins
In reply to: [SVG Support] Unsafe handling of SVG PathForum: Plugins
In reply to: [SVG Support] Unsafe handling of SVG PathHi @benbodhi,
Imagine the $svg file contains a utf8 character or an invalid path.
Instead of $svg being FALSE it will kick out an error. Because it won’t be FALSE, it will move to the ELSE statement.
That will then cause an error with $svg->attributes();
This is the bug I was getting.
I think you need to check if you can read $svg using is_file() or is_readable() etc along with basename and a path so that someone can’t use ../../ to do directory traversal through the code.
Once you know it’s a proper file, in an acceptable place on the drive, and that you can read it, then I think you should either try/catch it or add an error handler in case it fails. If the error handler’s not caught an error, and the $svg variable has returned a resource, then carry on to the else.
I think it’s just more error checking needed when you can’t control the origin of $svg.
These were my notes for it:
// add @ or otherwise validate this
// check this uses basepath()
// check the file exists
// check the file is readable
// check this is an SVGIs that something you can add?
Thanks,
MyStreamForum: Plugins
In reply to: [SVG Support] Unsafe handling of SVG PathHi @benbodhi,
Can you post your update here and I’ll try to offer any thoughts if I can?
Thank you 🙂
MyStreamForum: Plugins
In reply to: [SVG Support] Unsafe handling of SVG PathHi Benbodhi,
Perhaps:
function bodhi_svgs_get_dimensions( $svg ) { // Suppress errors internally libxml_use_internal_errors(true); // Create a known, reliable path $path = $_SERVER['DOCUMENT_ROOT'].'/path/to/svg/'.basename($svg); // Make sure it exists and can be read if(file_exists($path) && is_readable($path)) { $svg = simplexml_load_file( $path ); // Make sure the document returned is valid if(false !== $svg) { // Rest of your code here } } ...Forum: Plugins
In reply to: [SVG Support] Unsafe handling of SVG PathHi Benbodhi,
We downloaded the Origen theme from themeforest.net.
In this theme it references your plugin.
When we logged in to Customize the theme, we found the Customize menu didn’t load fully. When I checked the XHR requests in Firefox I noticed that the CSS file included a PHP error in the output.
I tracked that error to the file in your plugin.
The error seemed to be caused by the theme author’s use of a utf8 character in the filename of an svg file. When your file tried to load the file passed by the theme, it was not able to and generated an error notice that showed up in the rendering of the CSS file.
I added @ in front of the call to suppress the error, but it’s only a temporary fix.
Let me know if you would like any help fixing this one and I would be happy to try to assist.
Warmest thanks,
MyStream