Browse Source

[Web] Fix invalid encodings with json_encode, fixes #3847

andryyy 4 years ago
parent
commit
6d56ef6435

+ 2 - 0
data/web/inc/ajax/qitem_details.php

@@ -197,7 +197,9 @@ elseif (!empty($_GET['id']) && ctype_alnum($_GET['id'])) {
         exit;
         exit;
       }
       }
     }
     }
+    $data = mb_convert_encoding($data, "UTF-8", "auto");
     echo json_encode($data);
     echo json_encode($data);
   }
   }
+
 }
 }
 ?>
 ?>

+ 45 - 0
data/web/inc/lib/vendor/php-mime-mail-parser/php-mime-mail-parser/.github/workflows/main.yml

@@ -0,0 +1,45 @@
+name: CI
+
+on: [push]
+
+jobs:
+
+  tests:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        php: [7.1, 7.2, 7.3]
+        composer: ["", "--prefer-lowest"]
+    steps:
+    - uses: actions/checkout@v1
+    - name: Change PHP version
+      run: sudo update-alternatives --set php /usr/bin/php${{ matrix.php }} && php -v
+    - name: Install mailparse
+      run: sudo apt install php-mailparse
+    - name: Composer update
+      run: composer update ${{ matrix.composer }} --no-progress
+    - name: PhpUnit
+      run: php -d xdebug.profiler_enable=off ./vendor/bin/phpunit
+     
+  php-cs:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v1
+    - name: Composer update
+      run: composer update --no-progress --ignore-platform-reqs
+    - name: PHP CS
+      run: ./vendor/bin/phpcs src tests --standard=psr2
+     
+  coverage:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v1
+    - name: Install mailparse
+      run: sudo apt install php-mailparse
+    - name: Composer update
+      run: composer update --no-progress
+    - name: Codecov
+      run: |
+        ./vendor/bin/phpunit --coverage-clover=coverage.xml --whitelist src
+        bash <(curl -s https://codecov.io/bash) -t ${{ secrets.COVERALLS_REPO_TOKEN }}
+     

+ 6 - 4
data/web/js/site/qhandler.js

@@ -6,10 +6,6 @@ jQuery(function($){
     data: { hash: qitem },
     data: { hash: qitem },
     dataType: 'json',
     dataType: 'json',
     success: function(data){
     success: function(data){
-      if (typeof data.error !== 'undefined') {
-        qError.text(data.error);
-        qError.show();
-      }
       $('[data-id="qitems_single"]').each(function(index) {
       $('[data-id="qitems_single"]').each(function(index) {
         $(this).attr("data-item", qitem);
         $(this).attr("data-item", qitem);
       });
       });
@@ -62,6 +58,12 @@ jQuery(function($){
           $('#qid_detail_recipients').append(elem);
           $('#qid_detail_recipients').append(elem);
         });
         });
       }
       }
+    },
+    error: function(data){
+      if (typeof data.error !== 'undefined') {
+        qError.text("Error loading quarantine item");
+        qError.show();
+      }
     }
     }
   });
   });
 });
 });

+ 7 - 4
data/web/js/site/quarantine.js

@@ -139,10 +139,7 @@ jQuery(function($){
       data: { id: qitem },
       data: { id: qitem },
       dataType: 'json',
       dataType: 'json',
       success: function(data){
       success: function(data){
-        if (typeof data.error !== 'undefined') {
-          qError.text(data.error);
-          qError.show();
-        }
+
         $('[data-id="qitems_single"]').each(function(index) {
         $('[data-id="qitems_single"]').each(function(index) {
           $(this).attr("data-item", qitem);
           $(this).attr("data-item", qitem);
         });
         });
@@ -211,6 +208,12 @@ jQuery(function($){
         else {
         else {
           qAtts.text('-');
           qAtts.text('-');
         }
         }
+      },
+      error: function(data){
+        if (typeof data.error !== 'undefined') {
+          qError.text("Error loading quarantine item");
+          qError.show();
+        }
       }
       }
     });
     });
   });
   });