private void FixChangedFileNames(HtmlDom pageDom)
{
//NB: the original version of this was also concerned with hrefs. Since Bloom doesn't support making
//links and there were no unit tests covering it, I decided to drop that support for now.
foreach (XmlElement element in HtmlDom.SelectChildImgAndBackgroundImageElements(pageDom.RawDom.DocumentElement))
{
// Notice that we use only the path part of the url. For some unknown reason, some bloom books
// (e.g., El Nino in the library) have a query in some image sources, and at least some ePUB readers
// can't cope with it.
var path = HtmlDom.GetImageElementUrl(element).PathOnly.NotEncoded;
string modifiedPath;
if (_mapChangedFileNames.TryGetValue(path, out modifiedPath))
{
path = modifiedPath;
}
// here we're either setting the same path, the same but stripped of a query, or a modified one.
// In call cases, it really, truly is unencoded, so make sure the path doesn't do any more unencoding.
HtmlDom.SetImageElementUrl(new ElementProxy(element), UrlPathString.CreateFromUnencodedString(path, true));
}
}