All pastes #2104192 Raw Edit

Unnamed

public diff v1 · immutable
#2104192 ·published 2012-01-19 22:07 UTC
rendered paste body
[root@localhost Deki-mindtouch]# git diff src/services/Deki/DekiXmlParser.csdiff --cc src/services/Deki/DekiXmlParser.csindex 4ee0823,51c9325..0000000--- a/src/services/Deki/DekiXmlParser.cs+++ b/src/services/Deki/DekiXmlParser.cs@@@ -245,8 -245,8 +245,13 @@@ namespace MindTouch.Deki          private const string UNWANTED_XINHA_CODE_IN_ATTRIBUTES = "if(window.top && window.top.Xinha){return false}";          private const string ALL_HEADINGS_XPATH = ".//h1 | .//h2 | .//h3 | .//h4 | .//h5 | .//h6";          private const string ALL_NESTED_HEADINGS_XPATH = ".//h1[.//h1 | .//h2 | .//h3 | .//h4 | .//h5 | .//h6] | .//h2[.//h1 | .//h2 | .//h3 | .//h4 | .//h5 | .//h6] | .//h3[.//h1 | .//h2 | .//h3 | .//h4 | .//h5 | .//h6] | .//h4[.//h1 | .//h2 | .//h3 | .//h4 | .//h5 |++<<<<<<< HEAD +        private const string FILE_API_PATTERN = @"^/*{0}/(?<fileid>\d+)/=(?<filename>.+)$"; +++=======+         private const string FILE_API_PATTERN = @"^/*{0}/(?<fileid>\d+)/=?(?<filename>[^?]+)";+++>>>>>>> origin/master          //--- Class Methods ---          public static XDoc Include(string path, string section, bool showTitle, int? adjustHeading, DekiScriptLiteral args, int revision, bool followRedirects, bool returnEmptyDocIfNotFound, bool createAnchor) {              DekiScriptLiteral export;@@@ -2272,20 -2272,13 +2277,24 @@@          private void ProcessImages() {              if(ParserMode.VIEW == _mode || ParserMode.EDIT == _mode || ParserMode.VIEW_NO_EXECUTE == _mode) {++<<<<<<< HEAD +                // TODO (andyv): MT-10997 Evaluate new fileid, filename regex in DekiXmlParser::ProcessImages() for use throughout entire parser +                const string pattern = @"/{0}/(?<fileid>\d+)/=?(?<filename>[^?]+)"; +                var fileRegex = new Regex(String.Format(pattern, DekiContext.Current.ApiUri.At("files").Path.TrimStart('/')), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);++=======+                 var fileRegex = new Regex(String.Format(FILE_API_PATTERN, DekiContext.Current.ApiUri.At("files").Path.TrimStart('/')), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);++>>>>>>> origin/master                  var fileIds = new List<uint>(); -                foreach (XDoc img in _content[".//img"]) { +                foreach(XDoc img in _content[".//img"]) {                      var fileid = img["@fileid"].AsUInt ?? 0;                      if(0 == fileid) { -                        var m = fileRegex.Match(XUri.Decode(img["@src"].Contents)); +                        var c = img["@src"].Contents; +                        var contents = c.StartsWithInvariantIgnoreCase("@api") ? "/" + c : c; +                        if(c != contents) { +                            img["@src"].ReplaceValue(contents); +                        } +                        var m = fileRegex.Match(XUri.Decode(contents));                          if(!UInt32.TryParse(m.Groups["fileid"].Value, out fileid)) {                              continue;                          }