Skip to content
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

Mixed content http+xml (when POST) not detected correctly #992

Closed
dominch opened this issue Nov 23, 2015 · 12 comments
Closed

Mixed content http+xml (when POST) not detected correctly #992

dominch opened this issue Nov 23, 2015 · 12 comments
Labels
Milestone

Comments

@dominch
Copy link

dominch commented Nov 23, 2015

Hello,
There is problem with mixed content and http headers, they work for GET, but with POST wrong class is detected, examples:

Working one:

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Mon, 23 Nov 2015 14:59:23 GMT
Connection: close
Content-Length: 2838

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <foo xmlns="http://example.net/">
      <bar>
        <baz>
...

Wrong one:

POST /example.asmx HTTP/1.1
Host: example.net
Connection: close
User-Agent: PHP-SOAP/5.4.41
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://example.net/foo"
Content-Length: 1137

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://example.net/">
  <SOAP-ENV:Body>
    <ns1:foo>
      <ns1:bar>
...

Those are, both http+xml. First seems to detect correctly.
BTW: what, how can I force two classes in tag?

@Sannis Sannis added the bug label Nov 24, 2015
@Sannis Sannis self-assigned this Nov 24, 2015
@Sannis
Copy link
Collaborator

Sannis commented Nov 24, 2015

@dominch, can you please provide full listing for second example? Stripped one works good for me with master:
screen shot 2015-11-25 at 01 36 17

@isagalaev
Copy link
Member

Same here. Can't reproduce with the latest master code.

@dominch
Copy link
Author

dominch commented Nov 25, 2015

Hello, I just checked and indeed there is no problem with smaller xml, Here is smallest I could get to see the problem:

POST /Example/example.asmx HTTP/1.1
Host: exb2b
Connection: close
User-Agent: PHP-SOAP/5.4.41
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://example.net/AddExample"
Content-Length: 1448

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://example.net/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Body>
    <ns1:AddExample>
      <ns1:addExampleRequest>
        <ns1:comment xsi:nil="true"/>
        <ns1:exampleBy>
          <ns1:applicationFrom>hgw</ns1:applicationFrom>
          <ns1:userLogin>[email protected]</ns1:userLogin>
          <ns1:langCode>EN-US</ns1:langCode>
        </ns1:exampleBy>
        <ns1:testBy>
          <ns1:applicationFrom>ns</ns1:applicationFrom>
          <ns1:userLogin>[email protected]</ns1:userLogin>
          <ns1:langCode>EN-US</ns1:langCode>
        </ns1:testBy>
        <ns1:delivery>
          <ns1:iln>03</ns1:iln>
          <ns1:streetAndNumber xsi:nil="true"/>
          <ns1:postalCode xsi:nil="true"/>
          <ns1:contact xsi:nil="true"/>
        </ns1:delivery>
        <ns1:exampleLines>
          <ns1:exampleLine>
            <ns1:code>Test_123|CR; tap:KN75/01;</ns1:code>
            <ns1:fromId>198</ns1:fromId>
          </ns1:exampleLine>
        </ns1:exampleLines>
      </ns1:addExampleRequest>
    </ns1:AddExample>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I needed to obfuscate a bit real data, but You should clearly see the problem. This may be caused by <ns1:code>..../...</ns1:code> line but it's correct line and this character is ok at this place.
Strange thing is that removing some closed tags like <ns1:test /> fixes markup.

@isagalaev
Copy link
Member

Could you check again? I just pushed a related fix in master that might've fixed this too.

@dominch
Copy link
Author

dominch commented Nov 26, 2015

I would love to do so, but I can't build this lib :(

dominch@dev:~/dev/highlight.js$ node tools/build.js :common

/home/dominch/dev/highlight.js/tools/build.js:79
build     = require(`./${commander.target}`);
                    ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

Do You have any idea what is missing?
I tried to find files from last build in travis-ci but failed, only log file and nothing to get :(

@isagalaev
Copy link
Member

Likely it's because the build tool now requires node 4.x (sorry, we've been a sloppy with documenting this transition).

Incidentally, there's a snapshot browser build from yesterday https://highlightjs.org/static/tmp/highlight.pack.js that you can use to test it.

@Sannis Sannis added this to the 9.0 milestone Nov 27, 2015
@Sannis Sannis removed their assignment Nov 27, 2015
@dominch
Copy link
Author

dominch commented Nov 30, 2015

I still can't build it on this server, but I managed to check out version from link.
Results are different. With newer version both GET and POST looks the same in term of styles. Last time all GET were pink and POST (broken one) was mostly white-yellow, now both are... cyan (I'm using monokai-sublime theme).
I checked generated source and I think that new version is broken about xmls, Code generated on top is:

<span class="xml">
<span class="hljs-meta"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="hljs-tag">
<
<span class="hljs-name">SOAP-ENV:Envelope</span>
<span class="hljs-attr">xmlns:SOAP-ENV</span>
=
<span class="hljs-string">"http://schemas.xmlsoap.org/soap/envelope/"</span>
<span class="hljs-attr">xmlns:ns1</span>
=
<span class="hljs-string">"http://example.net/"</span>
>
</span>

older version was:

<span class="xml">
<span class="hljs-pi"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="hljs-tag">
<
<span class="hljs-title">SOAP-ENV:Envelope</span>
<span class="hljs-attribute">xmlns:SOAP-ENV</span>
=
<span class="hljs-value">"http://schemas.xmlsoap.org/soap/envelope/"</span>
<span class="hljs-attribute">xmlns:ns1</span>
=
<span class="hljs-value">"http://example.net/"</span>
>
</span>

Classes are changed since version I used. Maybe hljs-attribute is same as hljs-attr, but many other were changes. First line should be rather -pi than -meta.
Please correct me if I'm wrong, but this seems very strange to recolor whole xml specs.

@Sannis
Copy link
Collaborator

Sannis commented Nov 30, 2015

Classes are changed since version I used. Maybe hljs-attribute is same as hljs-attr, but many other were changes. First line should be rather -pi than -meta.
Please correct me if I'm wrong, but this seems very strange to recolor whole xml specs.

Version 9.0 will contains totally rethinked classes list synchronized across all languages, see #348.

@isagalaev
Copy link
Member

@dominch we had this problem before, that all the different styles didn't bother to work right with every language in all different edge cases. We redefined the whole class system recently, so now everything is a) consistent with each other and b) fixable :-) This is why you now see all HTTP verbs to be of one color.

The choice of specific class names is to ensure this consistency, and to the end user it shouldn't matter if it's "hljs-pi", or "hljs-meta", or whatever.

As of now, XML looks pretty okay to me with Monokai Sublime (barring any subjective feelings about the theme itself). Do you think something should look different?

@dominch
Copy link
Author

dominch commented Dec 1, 2015

This is big change and I didn't expected that.

I checked several themes and every theme marks first xml line just like any other string inside body. I think this is not correct, I liked when it was different. Now at tests I wasn't sure if it correctly detected xml. In far theme almost everything is now in one color.

I may have wrong css files (I used old ones), are those changed too?

I think original error is solved in this version.
Highlighting xml now works on every POST and GET I checked.

@isagalaev
Copy link
Member

The change was in the making for quite some time (since May, in fact), it only landed a few weeks ago.

I'm not sure what do you mean by "first XML line", but if it's the processing instruction in <? .. ?> then it definitely has a different class from the regular tags. And of course, you need the new CSS files, they have been changed according to the new class system.

(Closing the issue as it's solved.)

@dominch
Copy link
Author

dominch commented Dec 3, 2015

I tried updating new css, but no luck, still first xml line is not colored. I guess there is still something wrong with my build. I think original problem is solved and xml seems to be consistent. Thank for Your support. I'll give it a try at next release and hope to get that fully functional :) Thanks for Your support 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants