includepdf and file with comma

Even in 2017, putting spaces and commas in filenames is a bad idea, however

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{pdfpages}
\begin{document}
\typeout{===}
{\catcode`\,=11    \includepdf{abc,xyz}}
\typeout{===}
\end{document}

works as seen in the log:

===
[1 <./abc,xyz.pdf{/usr/local/texlive/2017/texmf-var/fonts/map/pdftex/updmap/pdf
tex.map}>]
===

Or if you really need a punctuation comma at the same time

{\catcode`\,=11 \gdef\zz{abc,xyz}}   \includepdf[keepaspectratio, pages={-}]{\zz}

\ExplSyntaxOn
\RenewDocumentCommand{\includepdf}{O{}m}
  {
   \tl_set:Nx \l_tmpa_tl { \tl_to_str:n { #2 } }
   \tl_replace_all:Nnf \l_tmpa_tl { , } { \char_generate:nn { `, } { 11 } }
   \ORIincludepdf[#1]{\l_tmpa_tl}
  }
\ExplSyntaxOff

The problem is that pdfpages uses the code for splitting the options also for managing the file name and so problems are to be expected when there is a comma in the file name. Indeed, it turns out that the file is loaded correctly, but when it's time to use it, the problem appears.

This can be cured by changing the commas in the file name into characters with different category code.

\documentclass{article}
\usepackage[multidot, extendedchars]{grffile}
\usepackage{pdfpages}
\usepackage{xparse,letltxmacro}

% save the original macro    
\LetLtxMacro\ORIincludepdf\includepdf

\ExplSyntaxOn
\RenewDocumentCommand{\includepdf}{O{}m}
 {
  % store the file name as a string
  \tl_set:Nx \l_tmpa_tl { \tl_to_str:n { #2 } }
  % replace commas (catcode 12) with commas (catcode 11)
  \tl_replace_all:Nnf \l_tmpa_tl { , } { \char_generate:nn { `, } { 11 } }
  \ORIincludepdf[#1]{\l_tmpa_tl}
 }
\cs_generate_variant:Nn \tl_replace_all:Nnn { Nnf }
\ExplSyntaxOff

\begin{document}

\includepdf[keepaspectratio,pages={-}]{file, with space, and comma.pdf}

\end{document}