IDN 을 사용하는 경우, 자바스크립트에서 도메인을 정확히 비교하지 못하는 문제 수정#1037
Closed
misol wants to merge 1 commit into
Closed
Conversation
To handle url on the javascript, convert the url to punycode. If not, `isSameOrigin` and return `false` when we compare `location.href` and `request_uri` even though they are same... On the normal domain (except IDN), they are not affected by this commit.
Member
|
대부분의 주소 관련 처리에서 URI.js를 사용하고 있는데, 여기서 제대로 비교를 못 하던가요? 아니면 수동으로 두 문자열을 비교할 때 문제가 생기는 건가요? |
Member
Author
|
@kijin /**
* @brief Check if two URLs belong to the same origin
*/
window.isSameOrigin = function(url1, url2) {
if(!url1 || !url2) {
return false;
}
if (url1.match(/^\.?\/[^\/]*/) || url2.match(/^\.?\/[^\/]*/)) {
return true;
}
if (url1.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i) || url2.match(/^(https?:)?\/\/[^\/]*[^a-z0-9\/.:_-]/i)) {
return false;
}
url1 = window.XE.URI(url1).normalizePort().normalizePathname().origin();
url2 = window.XE.URI(url2).normalizePort().normalizePathname().origin();
return (url1 === url2) ? true : false;
}; |
Member
|
@misol 그러면 애꿎은 전역변수가 아니라 해당 함수를 고쳐야겠네요. |
Member
Author
|
punycode 로 된 주소가 UTF-8 로 인코딩된 주소 문자열 보다는 이후에도 호환성이 나을 것 같다고 생각했습니다. 어느 쪽이든 찬성입니다 :) |
Member
Author
|
게다가 코드를 보시면 URI.js 에서도 적절한 값을 반환하지 못하는 것으로 생각되어서요... 어느쪽이든 제대로 동작한다면 찬성입니다. |
kijin
added a commit
that referenced
this pull request
May 30, 2018
kijin
added a commit
that referenced
this pull request
May 30, 2018
Member
|
Fixed in 1a3cbb7 |
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.
자바스크립트에
UTF-8인코딩된 주소를 넘겨줄 경우,location.href와의 비교조차 정확히 해내지 못하는 경우가 발생합니다.기왕 자바스크립트 변수로 넘겨준다면, punycode 인코딩 된 값으로 넘겨주도록 합니다.
IDN 이 아닌 일반 영문 알파벳 도메인인 경우에는 별도로 변환되는 일이 일어나지 않기 때문에 이 커밋으로 인한 영향은 거의 없습니다.