09.12.2021 How to edit the BLOB editor and copy paste
09.12.2021 How to edit the BLOB editor and copy paste
Hello
I want to be able to copy and paste into a blob text field.
With text, images, links .. it is for example to make tutorials with screenshots.
I do my capture, copy and paste afterwards.
I know that it is possible for example here:
https://www.sceditor.com/
Can we do it with APPGINI?
I want to be able to copy and paste into a blob text field.
With text, images, links .. it is for example to make tutorials with screenshots.
I do my capture, copy and paste afterwards.
I know that it is possible for example here:
https://www.sceditor.com/
Can we do it with APPGINI?
Re: 09.12.2021 How to edit the BLOB editor and copy paste
I make a screenshot
I make a COPY
I go to my APPGINI application, BLOB field I paste, the image appears, I SAVE the image disappears.
I make a COPY
I go to my APPGINI application, BLOB field I paste, the image appears, I SAVE the image disappears.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
hello
No idea ?
No idea ?
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hi,
do you only need the data to be shown in the DV? or also in the TV?
do you only need the data to be shown in the DV? or also in the TV?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hello
In detail DV this would already be very good.
In detail DV this would already be very good.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hi,
you can try this: Add to the hooks/TABLENAME.php -> _dv function
Replace FIELDNAME , TABLENAME , PRIMARYKEY with your data.
you can try this: Add to the hooks/TABLENAME.php -> _dv function
Code: Select all
if ($selectedID) {
$blob=sqlvalue("SELECT FIELDNAME from TABLENAME where PRIMARYKEY={$selectedID}");
$html.="<script>\$j(function() {\$j('#FIELDNAME').val('".$blob."')})</script>";
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Perfect ! merci
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Not everything is solved and it's very weird.
I make a copy paste of an image (145kB) APPGINI does NOT save it, I make the same collage through a forum type SMF SIMPLE MACHINE FORUM, it works!
I PASTE in SMF then I copy (ctrl + c) then I go to APPGINI, I make a PASTE (CTRL + V) and there miracle it saves me!
What for???
- Attachments
-
- 3.png (192.38 KiB) Viewed 4774 times
-
- 4.png (139.84 KiB) Viewed 4774 times
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hi,
sorry, I did not get your use case. Can you please explain the steps you do, so I may try to reproduce it.
sorry, I did not get your use case. Can you please explain the steps you do, so I may try to reproduce it.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hello
1) I make a screenshot with the WINDOWS CAPTURE tool, then COPY in the CAPTURE tool, COPY button or CTRL+ C
2) I go to my APPGINI online application and in the relevant field (BLOB) I make a PASTE (CTRL + V), my image appears. I save it disappears...
3) I do the same thing through another site where IS INSTALLED SIMPLE MACHINE FORUM SMF (forum like PHBB), I paste my image, and I make a COPY of the entire article (CTRL + A and CTRL + C)
4) I return to my online application APPGINI, I make a PASTE (CTRL + V), my article appears and I save and there miracle: my image is preserved!
1) I make a screenshot with the WINDOWS CAPTURE tool, then COPY in the CAPTURE tool, COPY button or CTRL+ C
2) I go to my APPGINI online application and in the relevant field (BLOB) I make a PASTE (CTRL + V), my image appears. I save it disappears...
3) I do the same thing through another site where IS INSTALLED SIMPLE MACHINE FORUM SMF (forum like PHBB), I paste my image, and I make a COPY of the entire article (CTRL + A and CTRL + C)
4) I return to my online application APPGINI, I make a PASTE (CTRL + V), my article appears and I save and there miracle: my image is preserved!
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Your use case #1
In TABLENAME_dml.php there is some sanitizing of database data. I guess this is one more security feature for avoiding Cross Site Scripting (XSS).
Find the lines where it says...
The second line iterates through all array items (AKA record values) and removes a lot of HTML tags. You can check by yourself if you dump out data before and after safe_html() has been applied.
In my test this was the result:
We can clearly see that the image-data came from the database but then was removed by applying safe_html function.
For proof I have skipped html-sanitizing by commenting out the line ( Caution: don't do that in production!) ...
...and then the image gets rendered as expected.
So, this is the reason why pasted images will not be displayed in nicEdit after reloading the page.
Your use case #2
Next to this first issue, you have reported that copied images from a different system get saved and restored on reload. I have taken a look at safe_html() function and there is a lot of functionality and parsing and regular expressions being executed for stripping html tags. I did not investigate, I can only guess that, in your second use case, you don't copy and paste binary image data, but a reference to an image, stored on a remote machine.
Exkurs: in Windows OS, when copying something into the clipboard, the clipboard contains the copied item in multiple available formats (dataFormats), for example as plain text, as richtext, as binary data. When pasting, the target accepts only supported dataFormats and takes the best matching dataFormat. For example Notepad accepts plain text only, but Wordpad also accepts Richtext.
As said before, I cannot promise that this is the reason in your 2nd usecase. You can find out by dumping $row before and after sanitizing. Then we should be able to see differences, if any.
Summary
In this first step I have searched for, found and named the reasons. Let's see your var_dump() results of your 2nd use case. As soon as we know the reason, we can try to find fixes for both use cases.
In TABLENAME_dml.php there is some sanitizing of database data. I guess this is one more security feature for avoiding Cross Site Scripting (XSS).
Find the lines where it says...
Code: Select all
$urow = $row; /* unsanitized data */
$row = array_map('safe_html', $row);
Code: Select all
$urow = $row; /* unsanitized data */
$cn ="description"; // this is the column name
var_dump($row[$cn]);
$row = array_map('safe_html', $row);
var_dump($row[$cn]);
exit;
In my test this was the result:
We can clearly see that the image-data came from the database but then was removed by applying safe_html function.
For proof I have skipped html-sanitizing by commenting out the line ( Caution: don't do that in production!) ...
Code: Select all
$urow = $row; /* unsanitized data */
// $row = array_map('safe_html', $row);
So, this is the reason why pasted images will not be displayed in nicEdit after reloading the page.
Your use case #2
Next to this first issue, you have reported that copied images from a different system get saved and restored on reload. I have taken a look at safe_html() function and there is a lot of functionality and parsing and regular expressions being executed for stripping html tags. I did not investigate, I can only guess that, in your second use case, you don't copy and paste binary image data, but a reference to an image, stored on a remote machine.
Exkurs: in Windows OS, when copying something into the clipboard, the clipboard contains the copied item in multiple available formats (dataFormats), for example as plain text, as richtext, as binary data. When pasting, the target accepts only supported dataFormats and takes the best matching dataFormat. For example Notepad accepts plain text only, but Wordpad also accepts Richtext.
As said before, I cannot promise that this is the reason in your 2nd usecase. You can find out by dumping $row before and after sanitizing. Then we should be able to see differences, if any.
Summary
In this first step I have searched for, found and named the reasons. Let's see your var_dump() results of your 2nd use case. As soon as we know the reason, we can try to find fixes for both use cases.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hi,
also I fully agree with Jan's explanations, I think to this issue the solution is simpler. You use a BLOB and want to store 145kb. According to the docs.
BLOB: A binary large object column with a maximum length of 65535 (2^16 - 1) bytes, or 64KB in storage. Each BLOB value is stored using a two-byte length prefix that indicates the number of bytes in the value.
MEDIUMBLOB: A binary large object column with a maximum length of 16777215 (2^24 - 1) bytes, or 16MB in storage. Each MEDIUMBLOB value is stored using a three-byte length prefix that indicates the number of bytes in the value.
LONGBLOB: A binary large object column with a maximum length of 4294967295 (2^32 - 1) bytes, or 4GB in storage. Each LONGBLOB value is stored using a four-byte length prefix that indicates the number of bytes in the value.
The image you try to store is just too big. So either you need to change your type for this field, or need to drop the size of the image.
I guess if you use the other system, the image is already compressed within that system and hence if you copy the image after saving to the other system and retrieving the image again, you will have an image with a smaller size that fits the BLOB capacity.
also I fully agree with Jan's explanations, I think to this issue the solution is simpler. You use a BLOB and want to store 145kb. According to the docs.
BLOB: A binary large object column with a maximum length of 65535 (2^16 - 1) bytes, or 64KB in storage. Each BLOB value is stored using a two-byte length prefix that indicates the number of bytes in the value.
MEDIUMBLOB: A binary large object column with a maximum length of 16777215 (2^24 - 1) bytes, or 16MB in storage. Each MEDIUMBLOB value is stored using a three-byte length prefix that indicates the number of bytes in the value.
LONGBLOB: A binary large object column with a maximum length of 4294967295 (2^32 - 1) bytes, or 4GB in storage. Each LONGBLOB value is stored using a four-byte length prefix that indicates the number of bytes in the value.
The image you try to store is just too big. So either you need to change your type for this field, or need to drop the size of the image.
I guess if you use the other system, the image is already compressed within that system and hence if you copy the image after saving to the other system and retrieving the image again, you will have an image with a smaller size that fits the BLOB capacity.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
I don't think it's a big problem, I've tried and always the same problem.
On the other hand if I look where is the image I paste (step 2 with SMF) I realize that this image is stored on www.i-imgur.com) so in my opinion it is a link, but it is completely transparent.
View image
On the other hand if I look where is the image I paste (step 2 with SMF) I realize that this image is stored on www.i-imgur.com) so in my opinion it is a link, but it is completely transparent.
View image
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Simple Machine Forum must send the image to i-imgur.com automatically and then retrieve the link... it's fast and convenient. I read that there is an API for that.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
I had set up my testing column as long blob and the problem was the same.
So the image size will become a problem when having sum(all content) > 4GB, as pböttcher has mentioned completely correct.
But even with smaller image sizes safe_html() strips out embedded images (base64 encoded data).
Your variable dump seems to proof my guess: after copying from different system (SMF) and pasting into nicEdit not the image itself but the href was pasted. This means you just have a hyperlink and rely on availability of that image over the network on the remote machine. It depends on your requirements if this is good or bad. Personally I'd like to be able to have the image itself (binary), not only the link.
So the image size will become a problem when having sum(all content) > 4GB, as pböttcher has mentioned completely correct.
But even with smaller image sizes safe_html() strips out embedded images (base64 encoded data).
Your variable dump seems to proof my guess: after copying from different system (SMF) and pasting into nicEdit not the image itself but the href was pasted. This means you just have a hyperlink and rely on availability of that image over the network on the remote machine. It depends on your requirements if this is good or bad. Personally I'd like to be able to have the image itself (binary), not only the link.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Oui JAN mais comment avoir cette image en binaire ?
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Please post in Englisch.
We have more than one problem to solve. Right now I don't know any bulletproof, copy & paste ready, hooks only solution, fixing all problems.
We have more than one problem to solve. Right now I don't know any bulletproof, copy & paste ready, hooks only solution, fixing all problems.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Sorry, I could not append to my prev answer. Forum denied saving
(Continued)
A good solution will have to...
Anyone else having ideas?
(Continued)
A good solution will have to...
- ...sanitize all data but keep base64 encoded images in richtext fields
- ...intercept pasting image hrefs, then download image, base64-encode data and paste <img/> having binary data instead of href
- ...deny pasting images if (content size + new image size) is bigger than max. of that field
- ...not be overwritten on next code generation
- ...be compatible with different image formats
- ...allow sizes depending on max. field size
Anyone else having ideas?
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Now that I have understood how image hosting works as on SMF, I will look for a solution to adapt to APPGINI.
As here for example
https://forum.forumactif.com/t381038-u ... r-d-image
As here for example
https://forum.forumactif.com/t381038-u ... r-d-image
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Great! I'm looking forward to your solution.
In between I have asked Ahmed about that safe_html() function and supporting base64 encoded images. Gonna report when I got an answer.
In between I have asked Ahmed about that safe_html() function and supporting base64 encoded images. Gonna report when I got an answer.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hi, just a short question. What version of AppGini are you running?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: 09.12.2021 How to edit the BLOB editor and copy paste
Hi again,
to be honest, I cannot reproduce your error. It just works fine as long as the settings are correct. Maybe you have additional code that acts. But with the native installation and the code provided above, it just works fine.
Maybe you can post the code you have added.
to be honest, I cannot reproduce your error. It just works fine as long as the settings are correct. Maybe you have additional code that acts. But with the native installation and the code provided above, it just works fine.
Maybe you can post the code you have added.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.