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

The optimized path is determined by NULL #1773

Closed
wants to merge 1 commit into from
Closed

Conversation

waydalee
Copy link

No description provided.

@twsouthwick
Copy link
Member

Can you provide details as to why you see this as a needed change?

@twsouthwick twsouthwick changed the title 优化路径为NULL的资源判断 The optimized path is determined by NULL Aug 20, 2024
@waydalee
Copy link
Author

waydalee commented Aug 21, 2024

您能否详细说明为什么您认为这是一项必要的更改?

并非所有值都是"NULL",我在使用过程中有碰到"XXX\XXX\NULL"这种值,如果没有过滤掉,会导致后续功能报错

@twsouthwick
Copy link
Member

Can you provide a sample document that has this? How was it created?

@tomjebo is this kind of thing expected from the spec?

@waydalee
Copy link
Author

我是在生产过程中碰到这种情况,暂时没有现成的案例。“XXX\XXX\NULL”是符合规范的吧?

@tomjebo
Copy link
Collaborator

tomjebo commented Aug 23, 2024

So I'm not sure where the "NULL" comes from in the original code:

                    if (!relationship.TargetUri.ToString().Equals("NULL", StringComparison.OrdinalIgnoreCase))

Should this really be:

                    if (!relationship.TargetUri.ToString().Equals("", StringComparison.OrdinalIgnoreCase))

An actual null byte in an URI isn't a problem on the surface although it does raise questions about security for me, aka null byte injection. But technically a null byte inside or at the end of a URI is valid.
An URI that is only a null byte, for example an empty string is not a valid URI and Sytem.Uri won't construct it.

@twsouthwick I searched our code and can't find where we might inject "NULL" into or in place of a Uri. Maybe I'm just missing it?

@tomjebo
Copy link
Collaborator

tomjebo commented Aug 23, 2024

@waydalee Please provide a document that has this condition ("NULL" in the relationship target URI).

@waydalee
Copy link
Author

@tomjebo
Copy link
Collaborator

tomjebo commented Aug 27, 2024

@waydalee did you create Microsoft.Word.docx with Microsoft Word or did you create it with code? Specifically, did Microsoft Word add:

 <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/NULL"/>

If Word added them can you tell me what steps you took to get Word to create them?

I've been playing with Word and trying different "NULL" strings added to relationship targets or replacing them with "NULL". Word seems to ignore these kinds of targets but also doesn't respect the relationship. But I'm not sure that Word does this itself.
As a matter of fact, I can add any invalid string to a relationship and Word will have the same behavior. I'll check with the Word product team to see if they recognize this.

@waydalee
Copy link
Author

是通过直接修改xml文件做的数据,可能不太恰当;由于是在生产过程中碰到的异常情况,当时情况紧急,通过调试发现文档中含有“XXX\XXX\NULL”,就直接修改源码编译成本地dll,后续的生产过程(超过一年)没有再发生过此类异常情况,所有手上没有真实的案例文档。

@tomjebo
Copy link
Collaborator

tomjebo commented Sep 9, 2024

@waydalee I found out more about the history of "NULL" in relationship target URIs. Office interprets a target URI containing only the string "NULL" to mean that the target points to nothing (no part). It was likely added for or by virus checkers to remove malicious URIs. However, target URIs that end with "NULL" but also contain otherwise valid URI characters are considered by Office to be valid target URIs and therefore, I would not approve adding this PR's proposed change.

Copy link
Collaborator

@tomjebo tomjebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Office product team, relationship targets with valid URI characters in addition to "NULL" (ending in "NULL") should be considered valid targets for loading.

@waydalee
Copy link
Author

According to Office product team, relationship targets with valid URI characters in addition to "NULL" (ending in "NULL") should be considered valid targets for loading.

如果碰到以NULL结尾的URI,会报异常:“Specified part does not exist in the package.”。是否应该修复这个异常?

@waydalee
Copy link
Author

我更关心的是SDK能兼容office能处理的文档

@tomjebo
Copy link
Collaborator

tomjebo commented Nov 19, 2024

From my earlier posting: target URIs that end with "NULL" but also contain otherwise valid URI characters are considered by Office to be valid target URIs and therefore, I would not approve adding this PR's proposed change.

I'm closing this.

@tomjebo tomjebo closed this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants