Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: module/Application/src/Application/View/Helper/Utf8Filter.php
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- module/Application/src/Application/View/Helper/Utf8Filter.php (revision )
- +++ module/Application/src/Application/View/Helper/Utf8Filter.php (revision )
- @@ -0,0 +1,62 @@
- +<?php
- +/**
- + * Perforce Swarm
- + *
- + * @copyright 2013 Perforce Software. All rights reserved.
- + * @license Please see LICENSE.txt in top-level folder of this distribution.
- + * @version <release>/<patch>
- + */
- +
- +namespace Application\View\Helper;
- +
- +use P4\Filter\Utf8;
- +use Zend\View\Helper\AbstractHelper;
- +
- +class Utf8Filter extends AbstractHelper
- +{
- + protected $utf8Filter = null;
- +
- + /**
- + * Filter utf-8 input, invalid UTF-8 byte sequences will be replaced with
- + * an inverted question mark.
- + *
- + * @param string|null $value the utf-8 input to filter
- + * @returns string the filtered result
- + */
- + public function __invoke($value)
- + {
- + $this->utf8Filter = $this->utf8Filter ?: new Utf8;
- + return $this->utf8Filter->filter($value);
- + }
- +}
- +<?php
- +/**
- + * Perforce Swarm
- + *
- + * @copyright 2013 Perforce Software. All rights reserved.
- + * @license Please see LICENSE.txt in top-level folder of this distribution.
- + * @version <release>/<patch>
- + */
- +
- +namespace Application\View\Helper;
- +
- +use P4\Filter\Utf8;
- +use Zend\View\Helper\AbstractHelper;
- +
- +class Utf8Filter extends AbstractHelper
- +{
- + protected $utf8Filter = null;
- +
- + /**
- + * Filter utf-8 input, invalid UTF-8 byte sequences will be replaced with
- + * an inverted question mark.
- + *
- + * @param string|null $value the utf-8 input to filter
- + * @returns string the filtered result
- + */
- + public function __invoke($value)
- + {
- + $this->utf8Filter = $this->utf8Filter ?: new Utf8;
- + return $this->utf8Filter->filter($value);
- + }
- +}
- Index: module/Projects/view/projects/index/edit.phtml
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- module/Projects/view/projects/index/edit.phtml (revision 4)
- +++ module/Projects/view/projects/index/edit.phtml (revision )
- @@ -196,8 +196,14 @@
- : '/project/add';
- $allMembers = array();
- foreach ($users as $user) {
- - $allMembers[] = $user->getId()
- - . ($user->getFullName() !== $user->getId() ? ' (' . $user->getFullName() . ')' : '');
- + // though unexpected, user id's/names can include invalid UTF-8 sequences so
- + // we filter them, otherwise our json_encode call could crash with an error.
- + // note, if the invalid sequence occurs in the user id portion; that user
- + // will not be an addable member.
- + $allMembers[] = $this->utf8Filter(
- + $user->getId()
- + . ($user->getFullName() !== $user->getId() ? ' (' . $user->getFullName() . ')' : '')
- + );
- }
- ?>
- <script type="text/javascript">
- Index: module/Application/config/module.config.php
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- module/Application/config/module.config.php (revision 5)
- +++ module/Application/config/module.config.php (revision )
- @@ -229,7 +229,8 @@
- 'permissions' => 'Application\View\Helper\Permissions',
- 'preformat' => 'Application\View\Helper\Preformat',
- 'qualifiedUrl' => 'Application\View\Helper\QualifiedUrl',
- - 'truncate' => 'Application\View\Helper\Truncate'
- + 'truncate' => 'Application\View\Helper\Truncate',
- + 'utf8Filter' => 'Application\View\Helper\Utf8Filter'
- ),
- ),
- 'controller_plugins' => array(
- Index: module/Projects/src/Projects/Filter/Project.php
- IDEA additional info:
- Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
- <+>UTF-8
- ===================================================================
- --- module/Projects/src/Projects/Filter/Project.php (revision 1)
- +++ module/Projects/src/Projects/Filter/Project.php (revision )
- @@ -11,6 +11,7 @@
- use Application\Filter\StringToId;
- use P4\Connection\ConnectionInterface as Connection;
- +use P4\Spec\User;
- use Projects\Model\Project as ProjectModel;
- use Zend\InputFilter\InputFilter;
- @@ -78,6 +79,7 @@
- );
- // ensure there is at least one team member
- + $knownIds = User::fetchAll(null, $p4)->invoke('getId');
- $this->add(
- array(
- 'name' => 'members',
- @@ -105,9 +107,15 @@
- array(
- 'name' => '\Application\Validator\Callback',
- 'options' => array(
- - 'callback' => function ($value) {
- + 'callback' => function ($value) use ($knownIds) {
- if (in_array(false, array_map('is_string', $value))) {
- return 'Member ids must be strings';
- + }
- +
- + foreach ($value as $id) {
- + if (!in_array($id, $knownIds)) {
- + return 'Unknown user id ' . $id;
- + }
- }
- return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement