<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/</id><updated>2025-11-11T08:43:46.723000Z</updated><subtitle>Recent posts to HTML 5 - Controls -&gt; Change Content-Security-Policy settings</subtitle><entry><title>HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/?limit=25#588e" rel="alternate"/><published>2025-11-11T08:43:46.723000Z</published><updated>2025-11-11T08:43:46.723000Z</updated><author><name>swol</name><uri>https://forge.codesys.com/u/swol/</uri></author><id>https://forge.codesys.com0cc82807c29cf4c7f0151511b5df8606f03259e1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Sorry for being late to the party... so it is not possible to use the webbrowser tool to display external websites in a visu anymore (without an unsafe amount of hacking)? We need to display data read from a Raspberry Pi in our webvisu and used to do it by entering the Pi's IP address as the URL variable in the webbrowser element but now (since I don't know when) "The page’s settings blocked the loading of a resource (frame-src) at 'safeURL' because it violates the following directive: “default-src 'self' 'unsafe-inline'”. What are the options for displaying the data?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/?limit=25#937b" rel="alternate"/><published>2022-11-02T08:23:34.919000Z</published><updated>2022-11-02T08:23:34.919000Z</updated><author><name>m.prestel</name><uri>https://forge.codesys.com/u/mprestel/</uri></author><id>https://forge.codesys.com3e1a085d1e8a8d21a93477ff3c55c41e1881710a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;strong&gt;Just a warning. Changing the generated csp and attributes on the iframe may allow bad people to run a DOS on your PLC causing a crash or loss of data.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/?limit=25#a0e8" rel="alternate"/><published>2022-10-31T09:30:34.809000Z</published><updated>2022-10-31T09:30:34.809000Z</updated><author><name>dalis</name><uri>https://forge.codesys.com/u/dalis/</uri></author><id>https://forge.codesys.com54de894500a52562f37c67f6d05994f178cb8a72</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello hx05,&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;"ContentSecurityPolicyIncludeTrustedOrigins" : "font-scr 'self' http://localhost:8080"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;is definitely wrong.&lt;/p&gt;
&lt;p&gt;You should use &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;"ContentSecurityPolicyIncludeTrustedOrigins" : "http://localhost:8080 https://raw.githubusercontent.com/LearnWebCode/json-example/master/"&lt;/span&gt;
&lt;span class="err"&gt;or just&lt;/span&gt;
&lt;span class="err"&gt;"ContentSecurityPolicyIncludeTrustedOrigins" : "*" (to allow any sources - i don't recommend that)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;According to &lt;a class="" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src" rel="nofollow"&gt;font-src&lt;/a&gt;, if font-src directive is absent, the user agent will look for the &lt;strong&gt;default-src&lt;/strong&gt; directive. So &lt;strong&gt;"*"&lt;/strong&gt; or &lt;strong&gt;"http://example.com/font/"&lt;/strong&gt; or &lt;strong&gt;'self' &lt;a href="http://localhost:8080/" rel="nofollow"&gt;&lt;/a&gt;&lt;a href="http://localhost:8080/" rel="nofollow"&gt;http://localhost:8080/&lt;/a&gt;&lt;/strong&gt; should be good enough. Try this firts, please, i haven't&lt;/p&gt;
&lt;p&gt;According to &lt;a class="" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/object-src" rel="nofollow"&gt;object-src&lt;/a&gt;,  it is recommended to restrict this fetch-directive (e.g. explicitly set object-src 'none' if possible). &lt;strong&gt;There must be a good reason why this value is set to 'none'.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The "home use" or just only for education purposes (my case), you could edit webvisu.js in visu directory of your PLC.&lt;br/&gt;
You find in this file &lt;strong&gt;"default-src {0}; object-src 'none'; script-src {0}; img-src {1}; style-src {2}; style-src-elem {2}; base-uri 'none';"&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The html iFrame and its CSP is generated by this webvisu.js:&lt;/p&gt;
&lt;p&gt;{0} is replaced with "'nonce-xxxxx' 'unsafe-inline' and content string in ContentSecurityPolicyIncludeTrustedOrigins (CSPITO).&lt;br/&gt;
{1} is replaced with 'self' &lt;a href="http://localhost:8080" rel="nofollow"&gt;http://localhost:8080&lt;/a&gt; (in win-plc), CSPITO and data:&lt;br/&gt;
{2} is replaced with 'nonce-xxxxxx' 'unsafe-inline' CSPITO and data:&lt;/p&gt;
&lt;p&gt;More about nonce &lt;a class="" href="https://content-security-policy.com/nonce/" rel="nofollow"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So you could change &lt;strong&gt;object-src 'none'&lt;/strong&gt; to &lt;strong&gt;object-src {0} or {1} or {2} or whatever-you-want&lt;/strong&gt;, save the file and try the behavior. &lt;/p&gt;
&lt;p&gt;Login with download rewrites webvisu.js and webvisu.cfg.json. To avoid that, just rename &lt;em&gt;Name of .htm file&lt;/em&gt; in Codesys (Visualization manager -&amp;gt; WebVisu) for example 'webvisu1.htm'. Also rename "upgraded" webvisu.js to webvisu_.js and change this in the generated webvisu.htm file as well ( &amp;lt;script language="javascript" src="webvisu_.js"&amp;gt;&amp;lt;/script&amp;gt;). Then call &lt;a href="http://..../8080/webvisu.htm" rel="nofollow"&gt;http://..../8080/webvisu.htm&lt;/a&gt; in a browser.&lt;/p&gt;
&lt;p&gt;Next Login with download generates &lt;em&gt;webvisu1.js&lt;/em&gt; and &lt;em&gt;webvisu1.cfg.json&lt;/em&gt; Your upgraded files will remain unaffected.&lt;/p&gt;
&lt;p&gt;If you also had a problem with &lt;strong&gt;Access-Control-Allow-Origin'&lt;/strong&gt; error message in a browser, it's because the html iFrame is sandboxed. &lt;strong&gt;sandbox="allow-scripts"&lt;/strong&gt;. Well, if you add &lt;strong&gt;allow-same-origin&lt;/strong&gt; you get rid of this message.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/?limit=25#d396/3746" rel="alternate"/><published>2022-10-27T09:14:28.934000Z</published><updated>2022-10-27T09:14:28.934000Z</updated><author><name>hx05</name><uri>https://forge.codesys.com/u/hx05/</uri></author><id>https://forge.codesys.come6a18b00521dd0611d834f0a082983d5fc88d22e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello dasis,&lt;/p&gt;
&lt;p&gt;as the documentaion (https://content.helpme-codesys.com/en/CODESYS%20Visualization/_visu_security_notes_html5.html) says, i change the config file (/PLCLogic/visu/webvisu.cfg.json) to: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;    "UpdateRate": 200,&lt;/span&gt;
&lt;span class="err"&gt;    "PlcAddress": "0301.3041",&lt;/span&gt;
&lt;span class="err"&gt;    "UseLocalHost": true,&lt;/span&gt;
&lt;span class="err"&gt;    "Application": "Application",&lt;/span&gt;
&lt;span class="err"&gt;    "StartVisu": "Visualization_Main",&lt;/span&gt;
&lt;span class="err"&gt;    "BestFit": true,&lt;/span&gt;
&lt;span class="err"&gt;    "LogLevel": "INFO",&lt;/span&gt;
&lt;span class="err"&gt;    "CommBufferSize": 50000,&lt;/span&gt;
&lt;span class="err"&gt;    "HasKeyboard": false,&lt;/span&gt;
&lt;span class="err"&gt;    "TouchHandlingActive": false,&lt;/span&gt;
&lt;span class="err"&gt;    "HandleTouchEvents": true,&lt;/span&gt;
&lt;span class="err"&gt;    "ScaleTypeIsotropic": true,&lt;/span&gt;
&lt;span class="err"&gt;    "BestFitForDialogs": true,&lt;/span&gt;
&lt;span class="err"&gt;    "RuntimeVersion": "3.5.18.20",&lt;/span&gt;
&lt;span class="err"&gt;    "LoginVisu": "",&lt;/span&gt;
&lt;span class="err"&gt;    "FillBackground": true,&lt;/span&gt;
&lt;span class="err"&gt;    "ContentSecurityPolicyIncludeTrustedOrigins" : "font-scr 'self' http://localhost:8080"&lt;/span&gt;
&lt;span class="err"&gt;} &lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;but this puts out a damaged CSP-Line:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;&amp;lt;meta http-equiv="Content-Security-Policy" content="&lt;/span&gt;
&lt;span class="err"&gt;default-src 'nonce-SWyWc7DbO4CI8cCrXQjjZw==' 'unsafe-inline' &lt;/span&gt;
&lt;span class="err"&gt;font-scr 'self' http://localhost:8080; &lt;/span&gt;
&lt;span class="err"&gt;object-src 'none'; &lt;/span&gt;
&lt;span class="err"&gt;script-src 'nonce-SWyWc7DbO4CI8cCrXQjjZw==' 'unsafe-inline' &lt;/span&gt;
&lt;span class="err"&gt;font-scr 'self' http://localhost:8080; &lt;/span&gt;
&lt;span class="err"&gt;img-src 'self' http://localhost:8080 &lt;/span&gt;
&lt;span class="err"&gt;font-scr 'self' http://localhost:8080 data:; &lt;/span&gt;
&lt;span class="err"&gt;style-src 'nonce-SWyWc7DbO4CI8cCrXQjjZw==' 'unsafe-inline' &lt;/span&gt;
&lt;span class="err"&gt;font-scr 'self' http://localhost:8080 data:; &lt;/span&gt;
&lt;span class="err"&gt;style-src-elem 'nonce-SWyWc7DbO4CI8cCrXQjjZw==' 'unsafe-inline' &lt;/span&gt;
&lt;span class="err"&gt;font-scr 'self' http://localhost:8080 data:; &lt;/span&gt;
&lt;span class="err"&gt;base-uri 'none';"&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Also, changes in the webvisu.cfg.json do not overwrite any values, only new ones are added but not i a workable way. &lt;br/&gt;
Therefore I think a change of&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;object-src 'none'&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;is currently not possible. What is your solution for "homen use"?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/?limit=25#d396" rel="alternate"/><published>2022-10-21T06:34:55.196000Z</published><updated>2022-10-21T06:34:55.196000Z</updated><author><name>dalis</name><uri>https://forge.codesys.com/u/dalis/</uri></author><id>https://forge.codesys.comeac787ae0686afe451eab9ff65aa60fe30643699</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;have You found a solution for this? I might have one, but only for home use! I am sure, it cannot be done by setting something in Codesys. Which is really sad, CSP is too restrictive for HTML5 components.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>HTML 5 - Controls -&gt; Change Content-Security-Policy settings</title><link href="https://forge.codesys.com/forge/talk/Visualization/thread/65f2d97f30/?limit=25#8bb7" rel="alternate"/><published>2022-09-21T14:52:24.325000Z</published><updated>2022-09-21T14:52:24.325000Z</updated><author><name>hx05</name><uri>https://forge.codesys.com/u/hx05/</uri></author><id>https://forge.codesys.com812d540c183ae225f97a9d915b78cbdabdc4f80b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello togheter,&lt;/p&gt;
&lt;p&gt;is there anyone who knows how to change the CSP-Settings inn the generateted HTML5 code for the controls?&lt;br/&gt;
By default CSP for object-scr is 'none' and font-src is not set, i would like to chnage it to: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;object-scr 'self' http://localhost:8080  data:; font-scr 'self' http://localhost:8080; &lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry></feed>