Issue #1630568: Validate that uploaded .po files are UTF8
Merge request reports
Activity
Filter activity
- Resolved by quietone
1377 1378 } 1378 1379 return $form_element; 1379 1380 } 1381 1382 function locale_validate_file_encoding(FileInterface $file, $encoding) { changed this line in version 2 of the diff
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); I don't know what the message should be but this does not look like it follows Drupal standards for user interface text. Looking at the other validation messages is should be more like "The file is not encoded with UTF-8." I would ask in #ux for advice.
I also wonder if the filename should be in the message. Not sure about that.
changed this line in version 2 of the diff
added 1 commit
added 1 commit
added 4685 commits
-
9b6cff4b...fb2469d3 - 4679 commits from branch
project:11.x
- e3d0372a - Add locale_validate_file_encoding method to locale.module
- 0fa307ca - Minor code changes
- 886184ee - #1630568 Rename function to file_validate_encoding() and move it to the file module.
- ff02c160 - Addressed drupal cs issue.
- 229be3a6 - #1630568 Write Unit test for file_validate_encoding
- 8a151075 - fix rebase
Toggle commit list-
9b6cff4b...fb2469d3 - 4679 commits from branch
- Resolved by quietone
- Resolved by quietone
- Resolved by quietone
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"; changed this line in version 10 of the diff
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"; changed this line in version 10 of the diff
added 9 commits
-
80e96707...4a41e572 - 8 commits from branch
project:11.x
- d1bdf174 - Merge branch '11.x' into '1630568-validate-that-uploaded'
-
80e96707...4a41e572 - 8 commits from branch
Please register or sign in to reply