How to add a HTTP header field in Openacs? - http-headers

I need to add a HTTP header field in the responses of a section of my site, the package instace (my section) is being viewed in a IFRAME and I want to declare a p3p field in order to be able to store cockies in IE 6/7/8 (login doesn't work well), I have an idea of how to do it in PHP and is quite simple:
<?php
header('P3P: CP="CAO PSA OUR"');
?>
but I didn't found how to do it in TCL/openacs, thanks for the help.

Based on Jim Lynch's response when you asked this question elsewhere, you just need to add it to the set of headers being produced for the page.
I'd guess that something like this is probably easiest (assuming you don't want to hard-code the contents of the header; if you did, you could simplify a little):
set cpflags "CAO PSA OUR"
ns_set cput [ns_conn outputheaders] "P3P" "CP=\"$cpflags\""
To understand it, you need to read about ns_conn and ns_set from the AOLserver docs, as well as set from the standard Tcl documentation.

Related

TYPO3: How to restrict the file upload in Powermail with the file formats

I am using powermail where I have added a file upload which I want to restrict with PNG,JPG and PDF file formats. Since I unfortunately do not work as long as TYPO3 and the extension Powermail I do not know exactly where I have to make the changes.
I have already seen in another forum post that you can make the adjustments in the setup.
plugin.tx_powermail.settings.setup.receiver.overwrite{
upload.file_extensions = jpg,png,pdf
}
Best regards
You can configure the allowed fileextension as TypoScript constant plugin.tx_powermail.misc.uploadFileExtensions.
So, the TypoScript (in constant section) should look like:
plugin.tx_powermail.misc {
uploadFileExtensions = jpg,png,pdf
}
file_extensions seems to be a configuration value years ago (The mentioned post was from 2011), but does not exist in the current powermail code.
It might be useful to know that in Powermail 9.0.2 this configuration doesn't work. This is how to acheive the same result in Powermail 9
plugin.tx_powermail.settings.setup.misc.file.extension = jpg,png,pdf

Is using Javascript in odoo.fields.HTML possible?

I want to integrate Adobe Captivate Content (Export: index.html, along with src-folder) into ODOO Community Edition v13 e-Learning Module (website_slides).
The slide.slide model already offers slide_type 'webpage' alongside the field 'html_content'.
The field 'html_content' is of type odoo.fields.HTML. To get the requirement stated above to work, I need to embed Javascript in the given html_content. It seems like the JS-scripts are not working. I also tried with a simple Hello World script.
Can someone help?
Best regards,
Lars
I found the solution already.
Looking at odoo/fields.py -> class Html, you can see that by default the given value is being sanitized using odoo/tools/mail.py -> html_sanitize(), which removes the HTML-Elements in 'tags_to_kill'. 'tags_to_kill' also contains "script".
After overriding html_content in slide.slide with the following, the Javascript-code is being executed:
html_content = fields.Html(
sanitize=False,
sanitize_tags=False,
sanitize_attributes=False)

Implementing List-Unsubscribe header(s) with swiftmailer (rfc2369, rfc6068, rfc8058, and friends)

Has anyone implemented the List-Unsubscribe & List-Unsubscribe-Post headers using swiftmailer ?
I know how to insert headers ...
$_headers = $message->getHeaders();
$_headers->addTextHeader( 'List-Unsubscribe', $list_unsubscribe );
if ( $has_dkim ) $_headers->addTextHeader( 'List-Unsubscribe-Post', 'List-Unsubscribe=One-Click' );
$list_unsubscribe variable may contain one <url> and/or one <mailto>
1st problem : Whatever the order of List-Unsubscribe and List-Unsubscribe-Post headers are set, they always appear in the wrong order (List-Unsubscribe-Post before List-Unsubscribe).
I tried to change header ordering using method defineOrdering, but that did not work as intended.
I even tried to hack the swiftmailer code to append those two new headers to the existing order list ... but did not work !
2nd problem : Would appreciate any hint on how to encode properly these two <url> & <mailto> using swiftmailer toolbox (i am also using the Decorator plugin).
Thank you for your answers.
So, 1st problem is solved !
According to RFC 5322
... header fields are not guaranteed to be in a particular order.

How to specify multiple values on siteSearch in google custom search api?

I'm using the google custom search api and want to create a search using the siteSearch:
https://www.googleapis.com/customsearch/v1?key=k&cx=cx&q=cocos2d&siteSearch=www.cocos2d-iphone.org&siteSearchFilter=i
and it works fine (returns all the result only from the given site).
Then I want to specify TWO sites to search so I tried to change the :
siteSearch=www.cocos2d-iphone.org
to
siteSearch=www.cocos2d-iphone.org www.XXXXXXXX.org
siteSearch=www.cocos2d-iphone.org|www.XXXXXXXX.org
siteSearch=www.cocos2d-iphone.org||www.XXXXXXXX.org
but none of these works.
hope someone can help here, thanks:)
Currently I don't believe you can specify more site through the query param siteSearch.
nevertheless you can configure your Custom Search Engine here: https://www.google.com/cse/manage/all
in the "Site to search" area.
This also works for excluding, as you can read here: https://support.google.com/customsearch/bin/answer.py?hl=en&answer=2631038&topic=2601037&ctx=topic
You cannot do this with the as_sitesearch parameter as that only accepts a single value. But you can achieve what you want with the as_q parameter, setting it to some value like: "site:google.com OR site:microsoft.com" - that will work in a similar way to this search.
The as_q parameter is documented here as:
The as_q parameter provides search terms to check for in a document.
This parameter is also commonly used to allow users to specify
additional terms to search for within a set of search results.
Examples q=president&as_q=John+Adams
Use "space" as seperator
Below is sample PHP code which works for me
$url="https://www.googleapis.com/customsearch/v1?key=k&cx=cx&q=cocos2d&siteSearch=".urlencode("www.cocos2d-iphone.org www.XXXXXXXX.org")."&siteSearchFilter=i"
Thanks,
Ojal Suthar

help to get rid of HTML special chars in database

I've migrated my site from interspire CMS to Joomla! CMS.
I've managed to migrate all the database of articles, but some of them have a weird issue - when I access the page from joomla, the title contains HTML entities like ’.
As you can guess from the CMS's I use, I rely on PHP as my server side, and MySql for my database.
I tried to go over the titles of the articles in the database with htmlspecialchars_decode AND html_entity_decode in order to get rid of those, but it had no effect.
if I just grab an example from the DB and echo it, it will look OK:
What’s Your Pleasure, Lasagna Or Pizza Manchester Style?
if I go to the article page in joomla it will look like this:
What’s Your Pleasure, Lasagna Or Pizza Manchester Style?
When I go to PhpMyAdmin to see directly what is in the database, this is the contents of the title:
What’s Your Pleasure, Lasagna Or Pizza Manchester Style?
I even tried to remove the symbol with:
str_replace("’","",$title);
or replace it like this
str_replace('’',"'",$title);
but nothing.
When I tried to encode it again instead of decoding it (just to see if i'm on the right DB) it worked and encoded it again...
Please, I would be glad to have any new ideas...
Thanks,
Yanipan
Try setting encoding to cp1252. This worked out for me:
$decoded = html_entity_decode($your_string, ENT_QUOTES, 'cp1252');
Probably your best bet is to do search and replace within the database itself vs trying to do it with php. Search and replace in mysql is done like this:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
So yours should look something like:
update ARTICLES set TITLE = replace(TITLE, '’', '\'');
Give that a shot.
Need more info
What is the character encoding on your database? That & or ;, may be something other than the typical ASCII.
It's possible that PHP/Joomla is double-encoding your string. Look at the browser's page source and find the text in the produced HTML. Instead of What’s, it might just be one of the following:
What&rsquo&59;s
What&38;rsquo&59;s
What&rsquo;s