Skip to content
Snippets Groups Projects

Issue #1630568: Validate that uploaded .po files are UTF8

Closed Issue #1630568: Validate that uploaded .po files are UTF8
7 unresolved threads
7 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 1377 1378 }
    1378 1379 return $form_element;
    1379 1380 }
    1381
    1382 function locale_validate_file_encoding(FileInterface $file, $encoding) {
  • 1377 1378 }
    1378 1379 return $form_element;
    1379 1380 }
    1381
    1382 function locale_validate_file_encoding(FileInterface $file, $encoding) {
    1383 $error = [];
    1384 if (!mb_check_encoding(file_get_contents($file->getFilename()), $encoding)) {
    1385 $error[] = sprintf("Your file is not %s encoded", $encoding);
  • added 1 commit

    • 127a130c - #1630568 Rename function to file_validate_encoding() and move it to the file module.

    Compare with previous version

  • Ravi Shankar added 1 commit

    added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • quietone changed the description

    changed the description

  • quietone changed target branch from 9.4.x to 11.x

    changed target branch from 9.4.x to 11.x

  • quietone added 4685 commits

    added 4685 commits

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • eb1e7e0e - Use plugin for file encoding validation

    Compare with previous version

  • added 1 commit

    • 0a42b7bb - Include test for invalid encoding

    Compare with previous version

  • 8
    9 /**
    10 * Defines an encoding constraint for files.
    11 */
    12 #[Constraint(
    13 id: 'FileEncoding',
    14 label: new TranslatableMarkup('Checks if a file is encoded with a specific encoding.', [], ['context' => 'Validation'])
    15 )]
    16 class FileEncodingConstraint extends SymfonyConstraint {
    17
    18 /**
    19 * The error message.
    20 *
    21 * @var string
    22 */
    23 public $message = "The file is not encoded with %encoding";
  • 15 )]
    16 class FileEncodingConstraint extends SymfonyConstraint {
    17
    18 /**
    19 * The error message.
    20 *
    21 * @var string
    22 */
    23 public $message = "The file is not encoded with %encoding";
    24
    25 /**
    26 * The missing extension message.
    27 *
    28 * @var string
    29 */
    30 public $extensionMessage = "The extension 'mbstring' is not installed";
  • added 1 commit

    • 56329b0f - Apply 3 suggestion(s) to 2 file(s)

    Compare with previous version

  • Kalle Vuorjoki added 2 commits

    added 2 commits

    • a8f3a951 - Dont require mbstring on composer
    • 80e96707 - Remove checking for native mbstring extension

    Compare with previous version

  • Kalle Vuorjoki added 9 commits

    added 9 commits

    Compare with previous version

  • quietone
  • assigned to @quietone

  • 1 <?php
    2
    3 namespace Drupal\file\Plugin\Validation\Constraint;
    4
    5 use Drupal\Core\StringTranslation\TranslatableMarkup;
    6 use Drupal\Core\Validation\Attribute\Constraint;
    7 use Symfony\Component\Validator\Constraint as SymfonyConstraint;
    8
    9 /**
    10 * Defines an encoding constraint for files.
    11 */
    12 #[Constraint(
    13 id: 'FileEncoding',
    14 label: new TranslatableMarkup('Checks if a file is encoded with a specific encoding.', [], ['context' => 'Validation'])
  • 15 )]
    16 class FileEncodingConstraint extends SymfonyConstraint {
    17
    18 /**
    19 * The error message.
    20 *
    21 * @var string
    22 */
    23 public string $message = "The file is not encoded with %encoding";
    24
    25 /**
    26 * The allowed file encoding.
    27 *
    28 * @var string
    29 */
    30 public string $encoding;
  • 8
    9 /**
    10 * Defines an encoding constraint for files.
    11 */
    12 #[Constraint(
    13 id: 'FileEncoding',
    14 label: new TranslatableMarkup('Checks if a file is encoded with a specific encoding.', [], ['context' => 'Validation'])
    15 )]
    16 class FileEncodingConstraint extends SymfonyConstraint {
    17
    18 /**
    19 * The error message.
    20 *
    21 * @var string
    22 */
    23 public string $message = "The file is not encoded with %encoding";
  • added 1 commit

    • 8c67e0dd - Apply 2 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    • f44fbed4 - Issue 1630568: Inform about correct encoding

    Compare with previous version

  • added 1 commit

    • 120ba64e - Issue 1630568: Update tests with mb_detect_encoding inaccurancy

    Compare with previous version

  • quietone
  • added 1 commit

    • faf8525a - Issue 1630568: Add tests for FileEncodingConstraint, change $encodings from string to an array

    Compare with previous version

  • added 1 commit

    • f85a3027 - Issue 1630568: Resolve CSPell issue

    Compare with previous version

  • Stephen Mustgrave added 153 commits

    added 153 commits

    • f85a3027...a9b0fa6d - 152 commits from branch project:11.x
    • d980e9fa - Merge branch '11.x' of github.com:drupal/drupal into 1630568-validate-that-uploaded

    Compare with previous version

  • closed

  • unassigned @quietone

  • Please register or sign in to reply
    Loading