Пример #1
0
        protected override MediaOptions GetOptions()
        {
            var result = base.GetOptions();

            if (result.Height > 0 || result.Width > 0 || result.Scale > 0)
            {
                if (!HashingUtils.IsUrlHashValid(InnerRequest.RawUrl))
                {
                    // hash invalid remove scaling
                    result.Height = 0;
                    result.Width  = 0;
                    result.Scale  = 0;
                }
            }
            return(result);
        }
Пример #2
0
        private void ReplaceReference(string renderedText, StringBuilder builder, int tagIndex, ref int index)
        {
            int urlStartIndex = renderedText.IndexOf("src", tagIndex, StringComparison.OrdinalIgnoreCase) + 3;

            urlStartIndex = renderedText.IndexOfAny(quotes, urlStartIndex) + 1;
            int urlEndIndex = renderedText.IndexOfAny(quotes, urlStartIndex);

            index = urlEndIndex;
            if (renderedText.IndexOf("?", urlStartIndex, urlEndIndex - urlStartIndex, StringComparison.Ordinal) < 0)
            {
                builder.Append(renderedText.Substring(tagIndex, urlEndIndex - tagIndex));
                return; // no parameters, no need to arm the URL;
            }
            string url = renderedText.Substring(urlStartIndex, urlEndIndex - urlStartIndex);

            url = HashingUtils.ProtectAssetUrl(url);
            builder.Append(renderedText.Substring(tagIndex, urlStartIndex - tagIndex));
            builder.Append(url);
            // we don't need to copy the rest of the tag as it will be supplemented in the next runs
        }