Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39040

Re: Chrome and passing on cross-origin

Newsgroups comp.lang.javascript
Subject Re: Chrome and passing on cross-origin
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References (3 earlier) <rmt1hd$204j$80@gallifrey.nk.ca> <rn04ao$tvh$33@gallifrey.nk.ca> <e346df7b-2f82-42d3-8adc-8f3e32b69c41n@googlegroups.com> <XnsAC61101EBF9eejj99@194.109.6.166> <16e67386-e0d3-49c2-b6a2-86d0992178a0n@googlegroups.com>
Date 2020-10-25 00:53 +0200
Message-ID <XnsAC61906C5C30eejj99@194.109.6.166> (permalink)

Show all headers | View raw


"Michael Haufe (TNO)" <tno@thenewobjective.com> wrote on 25 Oct 2020 in
comp.lang.javascript: 

>> <?php 
>> phpStringVar = 'Hello world.'; 
>> ?> 
>> <script> 
>> let jsStringVar = '<? = phpStringVar; ?>'; 
>> </script> 
>>
> [...]
> 
> This would still violate the Content Security Policy though.

Serverside there is no cross-origin restriction. the server can read 
anything it can find on the web by for instance using:

<?php
   fopen("http://google.com/", "r"); 
?>

<https://www.php.net/manual/en/function.fopen.php>

==================================

> No inline scripts allowed. 

The php scripts won't reach clientside, they are used in the serverside php-
engine and scrubbed from the html/css/javascript-stream. 

> Additionally I don't think the server will process *.js files by default

You mean php-engine processing, I presume.

Start with experimenting with putting all script in your .php file.

later you can make seperate js files,
which should either be extended as .php,

<script src = '/js/myJsFile.php' ></script>

Later you can perhaps accomodate the server to also preprocess js files].
However the separate js-files could be cached by the browser, so either 
prevent that, or use javscript in your main file.




> so `let jsStringVar = '<? = phpStringVar; ?>'; ` wouldn't do anything.
> 
> To make that work while obeying the CSP you'd have to do something like
> this in your .htaccess file: 
> 
> ```
> AddType application/x-httpd-php .js
> 
> AddHandler x-httpd-php5 .js
> 
> <FilesMatch "\.(js|php)$">
> SetHandler application/x-httpd-php
> </FilesMatch>
> ```
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-17 02:59 +0000
  Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-16 21:45 -0700
    Re: Chrome and passing on cross-origin "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-17 11:00 +0200
    Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-17 13:24 +0000
      Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-17 22:27 +0000
        Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-17 17:30 -0700
          Re: Chrome and passing on cross-origin "J.O. Aho" <user@example.net> - 2020-10-18 16:14 +0200
          Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-18 10:17 -0700
            Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-18 22:15 +0000
              Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-18 15:31 -0700
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-19 00:54 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-18 18:51 -0700
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-19 02:43 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-18 19:48 -0700
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-19 21:58 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-19 21:11 -0700
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-20 05:04 +0000
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-20 13:14 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-20 09:47 -0700
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-21 13:59 +0000
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-22 13:41 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-22 11:46 -0700
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-22 22:36 +0000
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-24 02:42 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-24 14:47 -0700
                Re: Chrome and passing on cross-origin "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-25 00:05 +0200
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-24 15:24 -0700
                Re: Chrome and passing on cross-origin "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-25 00:53 +0200
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-24 23:42 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-24 21:19 -0700
                Re: Chrome and passing on cross-origin "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-25 15:33 +0100
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-25 18:49 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-25 12:04 -0700
                Re: Chrome and passing on cross-origin "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-26 00:31 +0100
                Re: Chrome and passing on cross-origin doctor@doctor.nl2k.ab.ca (The Doctor) - 2020-10-26 00:44 +0000
                Re: Chrome and passing on cross-origin "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-10-20 09:47 -0700

csiph-web