- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.2k
 
[release/10.0.1xx] URL-encode scoped CSS Link headers for non-ASCII project names #51039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            lewing
  merged 7 commits into
  release/10.0.1xx
from
copilot/fix-43cc9698-4150-4c8c-a307-ed00dbbcd48e
  
      
      
   
  Oct 2, 2025 
      
    
      
        
          +112
        
        
          −0
        
        
          
        
      
    
  
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            7 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      0e1881a
              
                URL encode PackageId in scoped CSS asset paths to fix non-ASCII proje…
              
              
                Copilot dec378b
              
                Final verification that URL encoding fix works correctly
              
              
                Copilot f44a784
              
                Address feedback: revert unnecessary changes and fix test to use prop…
              
              
                Copilot 21a64d7
              
                Fix syntax error in test method
              
              
                Copilot 8555444
              
                fix test
              
              
                javiercn 95dcef5
              
                Fix encoding when generating the manifest instead
              
              
                javiercn 8704787
              
                Merge branch 'release/10.0.1xx' into copilot/fix-43cc9698-4150-4c8c-a…
              
              
                lewing File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -116,6 +116,8 @@ public override bool Execute() | |
| endpoint.AssetFile = asset.ResolvedAsset.ComputeTargetPath("", '/', StaticWebAssetTokenResolver.Instance); | ||
| endpoint.Route = route; | ||
| 
     | 
||
| EncodeLinkHeadersIfNeeded(endpoint); | ||
| 
     | 
||
| Log.LogMessage(MessageImportance.Low, "Including endpoint '{0}' for asset '{1}' with final location '{2}'", endpoint.Route, endpoint.AssetFile, asset.TargetPath); | ||
| } | ||
| 
     | 
||
| 
        
          
        
         | 
    @@ -137,6 +139,48 @@ public override bool Execute() | |
| return !Log.HasLoggedErrors; | ||
| } | ||
| 
     | 
||
| private static void EncodeLinkHeadersIfNeeded(StaticWebAssetEndpoint endpoint) | ||
| { | ||
| for (var i = 0; i < endpoint.ResponseHeaders.Length; i++) | ||
| { | ||
| ref var header = ref endpoint.ResponseHeaders[i]; | ||
| if (!string.Equals(header.Name, "Link", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| continue; | ||
| } | ||
| var headerValues = header.Value.Split([','], StringSplitOptions.RemoveEmptyEntries); | ||
                
      
                  lewing marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| for (var j = 0; j < headerValues.Length; j++) | ||
| { | ||
| ref var value = ref headerValues[j]; | ||
| value = EncodeHeaderValue(value); | ||
| } | ||
| header.Value = string.Join(",", headerValues); | ||
| } | ||
| } | ||
| 
     | 
||
| private static string EncodeHeaderValue(string header) | ||
| { | ||
| var index = header.IndexOf('<'); | ||
| if (index == -1) | ||
| { | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, better to make this   | 
||
| return header; | ||
| } | ||
| index++; | ||
| var endIndex = header.IndexOf('>', index); | ||
| if (endIndex == -1) | ||
| { | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar  | 
||
| return header; | ||
| } | ||
| var link = header.AsSpan(index, endIndex - index).ToString(); | ||
| var segments = link.Split('/'); | ||
| for (var j = 0; j < segments.Length; j++) | ||
| { | ||
| segments[j] = System.Net.WebUtility.UrlEncode(segments[j]); | ||
| } | ||
| var encoded = string.Join("/", segments); | ||
| return $"{header.Substring(0, index)}{encoded}{header.Substring(endIndex)}"; | ||
| } | ||
| 
     | 
||
| private static (string, string[]) ParseAndSortPatterns(string patterns) | ||
| { | ||
| if (string.IsNullOrEmpty(patterns)) | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.