Skip to content

Instantly share code, notes, and snippets.

View mlncn's full-sized avatar

Benjamin Melançon mlncn

View GitHub Profile
@mlncn
mlncn / security.md
Last active August 29, 2015 14:22 — forked from joelpittet/security.md
Correct a few typos and misspellings. No substantive changes.

Security

History

In Drupal 7 and prior versions we relied on manual escaping variables by our developers and themers. Every variable was either run through check_plain(), filter_xss() or another filter function manually or it was assumed to be safe. You can see where this assumption can easily be overlooked/forgotten and we end up with a security vulnerability usually in the form of an XSS attack.

One of the major decisions for choosing Twig in Drupal 8 was due to its autoescape security feature which all variables can be escaped automatically while they are printed. This alleviates a bunch of concerns and burden on the Security Team as well as protect Drupal Sites by default. This is equivalent to Drupal 7 writing <?php print check_plain($variable); ?> on each variable printed.

Flipping our security on its head aka Security Thought Process

@mlncn
mlncn / app.coffee
Last active December 17, 2015 01:38 — forked from jondot/app.coffee
class Thumb extends Backbone.Model
defaults:
uri: ''
state: ''
select: (state) ->
st = ''
st = 'selected' if state
@set('state' : st)
#!/bin/sh
# Pre-commit hook for git which removes trailing whitespace, converts tabs to spaces, and enforces a max line length.
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@mlncn
mlncn / tpl.html
Created September 3, 2011 00:32 — forked from jacine/tpl.html
hrm...
<span property="dc:date dc:created" content="2011-08-30T17:01:12-04:00" datatype="xsd:dateTime">
<time datetime="2011-08-30T21:01:12" pubdate="pubdate">30 Aug 2011</time>
</span>
@mlncn
mlncn / showspreadsheet.php
Created January 9, 2011 12:44 — forked from pamelafox/showspreadsheet.php
by Pamela Fox, a tiny code snippet for using PHP to render published Google spreadsheets as HTML, which she ported from (Ported from her similarly tiny Python + App Engine version here: https://github.com/pamelafox/pamelafox-site/blob/master/main.py
<?php
// Parsing this spreadsheet: https://spreadsheets.google.com/pub?key=0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc&hl=en&output=html
$url = 'http://spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json';
$file= file_get_contents($url);
$json = json_decode($file);
$rows = $json->{'feed'}->{'entry'};
foreach($rows as $row) {
echo '<p>';