Loading

Identify Malformed Trusted URLs

Дата публикации: Apr 7, 2026
Задача

In Summer ’26, Salesforce excludes malformed URLs from generated Content Security Policy (CSP) HTTP headers. Starting with Spring ’25, admins can’t save a malformed URL as a trusted URL. If an org has malformed URLs in its list, an admin added them before February 2025. To keep your Trusted URLs list accurate, remove any malformed entries.

Действия

1. Access the Developer Console

  • In Salesforce Classic, click Your Name, and then click Developer Console.

  • In Lightning Experience, click the quick access menu (the gear symbol), and then click Developer Console.

2. Execute the Scan

  1. Go to Debug > Open Execute Anonymous Window.

  2. Paste the Apex code into the execution window.

    // Define a regex pattern that will match valid domain definitions.
    Pattern validUrl = Pattern.compile(
        '[A-Za-z0-9\'' + Pattern.quote('-._~:@!$&()*+,;%=/?#[]') + ']+'); 
    
    // Fetch all CspTrustedSite for this org.
    List<CspTrustedSite> cspTrustedSites = [
        SELECT ID, EndpointUrl 
        FROM CspTrustedSite 
    ];
    
    // Loop over all CspTrustedSites and test if the URL is correct.
    for(CspTrustedSite entry : cspTrustedSites) {
        Matcher m = validUrl.matcher(entry.EndpointUrl);
        // When the URL is not valid, print a debug message.
        if(!m.matches()) {
            System.debug(logginglevel.INFO, 'URL: ' + entry.EndpointUrl);
        }
    }

  1. Select Open Log so the results appear automatically after execution.

  2. Click Execute.

3. Review Results

  1. After the execution log opens, select the Debug Only filter box. This filters the list to show only the malformed URLs.

  2. Review the list of malformed URLs shown in the filtered log.

4. (Optional) Export Findings

To export a full list of results, download the log file.

  1. Click File > Download Log.

  2. Open the downloaded file in a text editor.

  3. Search for the USER_DEBUG prefix to find the identified malformed URLs in the full log.

Дополнительные ресурсы

Salesforce Help: Open the Developer Console

Salesforce Help: Manage Trusted URLs

Номер статьи базы знаний

005317938

 
Загрузка
Salesforce Help | Article