XML 작성시 CDATA에 의존하지 않고 문자열을 제대로 escape합니다.#2042
Merged
1 commit merged intoApr 6, 2017
Merged
Conversation
Contributor
|
드디어 반영되네요. 개인적으로 최근 개발 중에 이 패치가 아니면 해결이 안되는 애로사항이 발생해서 고민하다가 프론트엔드에서 꼼수로 우회한 적이 있습니다. |
Contributor
Author
|
IE11을 제외한 브라우저에서 HTML 콘텐츠를 XML에 넣어 전달할 경우 escape된 상태 그대로 반환되는 문제를 발견했습니다. 새로고침 없는 댓글 기능 같은 서드파티 자료에서 많이 사용하는 기능입니다. 예를 들어 이렇게 HTML 콘텐츠를 넣으면 IE11에서는 로 돌아오지만 그 밖의 브라우저에서는 로 돌아오네요. 이 모든 문제의 원인은 11년째 업데이트되지 않고 있는 우선 IE11을 제외한 브라우저에서 text node의 값을 자동으로 unescape하여 반환하도록 수정해 보았습니다. 이 PR을 적용한 정식버전을 릴리즈하기 전에 반드시 고쳐져야 합니다. c77bee8 또다른 해결책으로는 |
kijin
added a commit
to rhymix/rhymix
that referenced
this pull request
Apr 10, 2017
ghost
pushed a commit
that referenced
this pull request
May 29, 2017
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
에디터가 아닌 textarea로 댓글을 쓰거나, 그 밖의 모듈에서 문자열 데이터를
exec_xml()함수로 서버에 전송할 때 내용에]]>문자 조합이 들어가면 정상 작동하지 않고 메인화면으로 튕기는 문제가 있습니다.XML 방식으로
]]>문자 조합이 들어간 데이터를 받아보려고 할 때도 마찬가지입니다. 디코딩할 수 없는 엉터리 XML이 반환됩니다.문제의 원인은 XE에서 XML을 작성할 때 모든 문자열을
<[CDATA[]]>로 감싸는데, 그 안에 또]]>가 들어가면 데이터를 받는 쪽에서 파싱에 실패하기 때문입니다.<[CDATA[]]>안에서]]>문자 조합을 표현하는 방법이 없는 것은 아니지만 (문자열을 두 개 이상으로 나누어 각각<[CDATA[]]>로 묶으면 됩니다) 이렇게 하면 코드가 불필요하게 복잡해지는 것은 물론, XML 데이터를 받아서 쓰는 클라이언트 어플리케이션이 오류를 일으킬 가능성도 있고, 무엇보다도<[CDATA[]]>에만 의존하다 보면 XML 구조 내에서 다른 의미로 해석될 가능성이 있는 특수문자가 제대로 걸러지지 않아 나중에 애매한 버그나 보안취약점으로 연결될 위험이 있습니다.IE11에서는 정상적인
<[CDATA[]]>태그도 중간에 다른 특수문자가 들어가면 잘못 해석되어 문자열이 깨져서 나오기도 합니다. 몇몇 사이트에서 이와 관련된 문제가 보고되고 있습니다.이 PR에서는 서버단 및 클라이언트단에서 XML을 작성할 때 문자열을
<[CDATA[]]>로 감싸지 않고htmlspecialchars()또는 이에 준하는 방법으로 제대로 인코딩하여, 내용에 어떤 특수문자 조합이 들어가더라도 잘못 해석될 여지를 완전히 제거하였습니다. 이렇게 인코딩된 문자열은 XML 파싱 과정에서 원래의 문자열로 정확하게 복원됩니다.