Skip to content
Snippets Groups Projects
Commit 7453f0a2 authored by joelpittet's avatar joelpittet Committed by MegaChriz
Browse files

Issue #2557581 by joelpittet: CSV column names escaped & upload field double escaping

parent 21ff5904
No related branches found
No related tags found
No related merge requests found
...@@ -354,7 +354,7 @@ function theme_feeds_upload($variables) { ...@@ -354,7 +354,7 @@ function theme_feeds_upload($variables) {
$summary .= '<div class="feeds-file-info">'; $summary .= '<div class="feeds-file-info">';
$summary .= '<div class="feeds-file-name">'; $summary .= '<div class="feeds-file-name">';
if ($wrapper) { if ($wrapper) {
$summary .= l(check_plain($file->filename), $wrapper->getExternalUrl()); $summary .= l($file->filename, $wrapper->getExternalUrl());
} }
else { else {
$summary .= t('URI scheme %scheme not available.', array('%scheme' => file_uri_scheme($uri))); $summary .= t('URI scheme %scheme not available.', array('%scheme' => file_uri_scheme($uri)));
......
...@@ -124,20 +124,20 @@ class FeedsCSVParser extends FeedsParser { ...@@ -124,20 +124,20 @@ class FeedsCSVParser extends FeedsParser {
$sources = $uniques = array(); $sources = $uniques = array();
foreach ($mappings as $mapping) { foreach ($mappings as $mapping) {
if (strpos($mapping['source'], ',') !== FALSE) { if (strpos($mapping['source'], ',') !== FALSE) {
$sources[] = '"' . check_plain($mapping['source']) . '"'; $sources[] = '"' . $mapping['source'] . '"';
} }
else { else {
$sources[] = check_plain($mapping['source']); $sources[] = $mapping['source'];
} }
if (!empty($mapping['unique'])) { if (!empty($mapping['unique'])) {
$uniques[] = check_plain($mapping['source']); $uniques[] = $mapping['source'];
} }
} }
$sources = array_unique($sources); $sources = array_unique($sources);
$output = t('Import !csv_files with one or more of these columns: !columns.', array('!csv_files' => l(t('CSV files'), 'http://en.wikipedia.org/wiki/Comma-separated_values'), '!columns' => implode(', ', $sources))); $output = t('Import !csv_files with one or more of these columns: @columns.', array('!csv_files' => l(t('CSV files'), 'http://en.wikipedia.org/wiki/Comma-separated_values'), '@columns' => implode(', ', $sources)));
$items = array(); $items = array();
$items[] = format_plural(count($uniques), 'Column <strong>!columns</strong> is mandatory and considered unique: only one item per !columns value will be created.', 'Columns <strong>!columns</strong> are mandatory and values in these columns are considered unique: only one entry per value in one of these column will be created.', array('!columns' => implode(', ', $uniques))); $items[] = format_plural(count($uniques), 'Column <strong>@columns</strong> is mandatory and considered unique: only one item per @columns value will be created.', 'Columns <strong>@columns</strong> are mandatory and values in these columns are considered unique: only one entry per value in one of these column will be created.', array('@columns' => implode(', ', $uniques)));
$items[] = l(t('Download a template'), 'import/' . $this->id . '/template'); $items[] = l(t('Download a template'), 'import/' . $this->id . '/template');
$form['help'] = array( $form['help'] = array(
'#prefix' => '<div class="help">', '#prefix' => '<div class="help">',
...@@ -215,16 +215,16 @@ class FeedsCSVParser extends FeedsParser { ...@@ -215,16 +215,16 @@ class FeedsCSVParser extends FeedsParser {
$mappings = feeds_importer($this->id)->processor->config['mappings']; $mappings = feeds_importer($this->id)->processor->config['mappings'];
$sources = $uniques = array(); $sources = $uniques = array();
foreach ($mappings as $mapping) { foreach ($mappings as $mapping) {
if (in_array(check_plain($mapping['source']), $uniques) || in_array(check_plain($mapping['source']), $sources)) { if (in_array($mapping['source'], $uniques) || in_array($mapping['source'], $sources)) {
// Skip columns we've already seen. // Skip columns we've already seen.
continue; continue;
} }
if (!empty($mapping['unique'])) { if (!empty($mapping['unique'])) {
$uniques[] = check_plain($mapping['source']); $uniques[] = $mapping['source'];
} }
else { else {
$sources[] = check_plain($mapping['source']); $sources[] = $mapping['source'];
} }
} }
$sep = $this->config['delimiter']; $sep = $this->config['delimiter'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment