Issue - Strange characters in PDF name, occurs when there are special characters in quote name. #4178

Open
opened 2026-02-20 16:14:35 -05:00 by deekerman · 4 comments
Owner

Originally created by @Jonatanestam on GitHub (Dec 30, 2019).

Issue

When I send email and there are special characters in quote name, the addressee get a file with strange characters in the PDF name.
2

Expected Behavior

No strange characters in the PDF name.

Actual Behavior

Strange characters in the PDF name.
Like: UTF-8QCotizaci=C3=B3n=5FCanal=5FChoice=2Epdf=

Possible Fix

Edit File modules/Emails/Email.php
around the line number 3055 add
setlocale(LC_ALL, "en_US.utf8"); $filename = iconv('UTF-8','ASCII//TRANSLIT',$filename); $filename = str_replace('_', '.', $filename);
3
4

Steps to Reproduce

  1. Click on Sales-->Quotes
  2. Select and click on a Quote
  3. Click on Actions tab.
  4. Click on Email PDF.
  5. Send Email PDF.
    1

Your Environment

*SuiteCRM Version used: Version 7.11.9 Sugar Versión 6.5.25 (Build 344)
*Browser name and version: Firefox, Chrome, Opera.
*Environment name and version: PHP v7.2.19
*Operating System and version: CentOS Linux release 7.6.1810.2.el7.centos.x86_64GNU/Linux
*Linux Kernel: 3.10.0-957.12.1.el7.x86_64
*CPU: Intel® Core™ i7 CPU 870 @ 2.93GHz
*RAM: MemTotal: 16163660 kB

Originally created by @Jonatanestam on GitHub (Dec 30, 2019). #### Issue When I send email and there are special characters in quote name, the addressee get a file with strange characters in the PDF name. ![2](https://user-images.githubusercontent.com/12118083/71597513-0f52b500-2b09-11ea-8872-d3a448205ae2.png) #### Expected Behavior No strange characters in the PDF name. #### Actual Behavior Strange characters in the PDF name. Like: **UTF-8QCotizaci=C3=B3n=5FCanal=5FChoice=2Epdf=** #### Possible Fix Edit File **modules/Emails/Email.php** around the line number **3055** add `setlocale(LC_ALL, "en_US.utf8"); $filename = iconv('UTF-8','ASCII//TRANSLIT',$filename); $filename = str_replace('_', '.', $filename);` ![3](https://user-images.githubusercontent.com/12118083/71597519-1a0d4a00-2b09-11ea-8a4a-2eb28079df24.png) ![4](https://user-images.githubusercontent.com/12118083/71597956-c69bfb80-2b0a-11ea-926c-8eca4afdcce5.png) #### Steps to Reproduce 1. Click on Sales-->Quotes 2. Select and click on a Quote 3. Click on Actions tab. 4. Click on Email PDF. 5. Send Email PDF. ![1](https://user-images.githubusercontent.com/12118083/71597483-f5b16d80-2b08-11ea-87cf-89669b55dc30.png) #### Your Environment *SuiteCRM Version used: Version 7.11.9 Sugar Versión 6.5.25 (Build 344) *Browser name and version: Firefox, Chrome, Opera. *Environment name and version: PHP v7.2.19 *Operating System and version: CentOS Linux release 7.6.1810.2.el7.centos.x86_64GNU/Linux *Linux Kernel: 3.10.0-957.12.1.el7.x86_64 *CPU: Intel® Core™ i7 CPU 870 @ 2.93GHz *RAM: MemTotal: 16163660 kB
Author
Owner

@Mausino commented on GitHub (Dec 30, 2019):

@Jonatanestam should you create the pull request?

@Mausino commented on GitHub (Dec 30, 2019): @Jonatanestam should you create the pull request?
Author
Owner

@pgorod commented on GitHub (Jan 10, 2020):

An easy way to start a PR from the right branch, and with an up-to-date branch, is this (everything from GitHub web site, which is very convenient, but only for very simple PR's that touch only a file or two):

  1. On GitHub, click "Code" tab and Navigate to the correct branch (hotfix-7.10.x). You can find the branch navigator on the left, above the file list:
    image

  2. Now navigate the directories to get to the file you want to change.

  3. Click the edit button (with a pencil icon). GitHub will fork the repo to your own area, if it's not forked already; and it will start a new branch from a completely up-to-date hotfix-7.10.x branch, which is what we want.

  4. Make your changes in the editor. When you save, it creates a commit in the new branch (called patch-1 for example) in your forked repo.

  5. It will then offer to start a PR from there into SalesAgility/SuiteCRM.

  6. The best thing is that, if you later need to change something, all you need to do is add more commits or edit more files in your repo, in that patch branch, and the PR will be updated automatically to include all that.

I hope this helps.

@pgorod commented on GitHub (Jan 10, 2020): An easy way to start a PR from the right branch, and with an up-to-date branch, is this (everything from GitHub web site, which is very convenient, but only for very simple PR's that touch only a file or two): 1. On GitHub, click **"Code" tab** and Navigate to the **correct branch** (`hotfix-7.10.x`). You can find the branch navigator on the left, above the file list: ![image](https://user-images.githubusercontent.com/15945027/72179791-993e3000-33dd-11ea-8d66-3eeba968b5fb.png) 2. Now navigate the directories to **get to the file** you want to change. 3. Click the **edit button** (with a pencil icon). GitHub will fork the repo to your own area, if it's not forked already; and it will start a new branch from a completely up-to-date `hotfix-7.10.x` branch, which is what we want. 4. **Make your changes** in the editor. When you **save**, it creates a commit in the new branch (called `patch-1` for example) in your forked repo. 5. It will then offer to **start a PR** from there into SalesAgility/SuiteCRM. 6. The best thing is that, if you later need to change something, all you need to do is **add more commits** or edit more files **in your repo, in that patch branch**, and the PR will be updated automatically to include all that. I hope this helps.
Author
Owner

@pgorod commented on GitHub (Jan 11, 2020):

A question - is that setlocale really necessary? That affects the entire PHP process, not just the current thread. I wonder if it could have nasty side-effects. These things are very hard to test appropriately since there are so many different language set ups out there...

If this code worked without that command (which it should, although the iconv documentation does mention some quirky behaviours related to locales), it would be much less risky.

If it is necessary to make the code work, then a solution like this one could be better: save the current setting, change it temporarily just for the iconv call, then put it back the way it was.

@pgorod commented on GitHub (Jan 11, 2020): A question - is that `setlocale` really necessary? That affects the entire PHP process, not just the current thread. I wonder if it could have nasty side-effects. These things are very hard to test appropriately since there are so many different language set ups out there... If this code worked without that command (which it _should_, although the `iconv` documentation does mention some quirky behaviours related to locales), it would be much less risky. If it is necessary to make the code work, then a solution like [this one](https://stackoverflow.com/a/33011249/1189711) could be better: save the current setting, change it temporarily just for the `iconv` call, then put it back the way it was.
Author
Owner

@pgorod commented on GitHub (Mar 5, 2020):

@khan01 did you see my comment above?

@pgorod commented on GitHub (Mar 5, 2020): @khan01 did you see my comment above?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4178
No description provided.