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

Fix unwanted VAST XML linebreaks #1952

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/org/prebid/server/vast/VastModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public String createBidVastXml(String bidder,
private static String resolveVastXmlFrom(String bidAdm, String bidNurl) {
return StringUtils.isEmpty(bidAdm) && bidNurl != null
? """
<VAST version="3.0"><Ad><Wrapper>
<AdSystem>prebid.org wrapper</AdSystem>
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>
<Creatives></Creatives>
<VAST version="3.0"><Ad><Wrapper>\
<AdSystem>prebid.org wrapper</AdSystem>\
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>\
<Creatives></Creatives>\
</Wrapper></Ad></VAST>""".formatted(bidNurl)
: bidAdm;
}
Expand Down
34 changes: 20 additions & 14 deletions src/test/java/org/prebid/server/vast/VastModifierTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ public void modifyVastXmlShouldModifyVastAndAppendUrl() {
INTEGRATION);

// then
final String modifiedVast = "<VAST version=\"3.0\"><Ad><Wrapper><AdSystem>prebid.org wrapper</AdSystem>"
+ "<VASTAdTagURI><![CDATA[adm2]]></VASTAdTagURI><Impression></Impression>"
+ "<Impression><![CDATA[http://external-url/event]]></Impression>"
+ "<Creatives></Creatives></Wrapper></Ad></VAST>";
final String modifiedVast =
"""
<VAST version="3.0"><Ad><Wrapper><AdSystem>prebid.org wrapper</AdSystem>\
<VASTAdTagURI><![CDATA[adm2]]></VASTAdTagURI><Impression></Impression>\
<Impression><![CDATA[http://external-url/event]]></Impression><Creatives>\
</Creatives></Wrapper></Ad></VAST>\
""";

assertThat(result).isEqualTo(new TextNode(modifiedVast));
}
Expand Down Expand Up @@ -341,20 +344,23 @@ private static TextNode nodeAdm() {
}

public static String adm() {
return "<VAST version=\"3.0\"><Ad><Wrapper>"
+ "<AdSystem>prebid.org wrapper</AdSystem>"
+ "<VASTAdTagURI><![CDATA[adm2]]></VASTAdTagURI>"
+ "<Impression></Impression><Creatives></Creatives>"
+ "</Wrapper></Ad></VAST>";
return """
<VAST version="3.0"><Ad><Wrapper>\
<AdSystem>prebid.org wrapper</AdSystem><VASTAdTagURI>\
<![CDATA[adm2]]></VASTAdTagURI><Impression>\
</Impression><Creatives></Creatives>\
</Wrapper></Ad></VAST>\
""";
}

private static String modifiedAdm(String bidNurl) {
return """
<VAST version="3.0"><Ad><Wrapper>
<AdSystem>prebid.org wrapper</AdSystem>
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>
<Creatives></Creatives>
</Wrapper></Ad></VAST>""".formatted(bidNurl);
<VAST version="3.0"><Ad><Wrapper>\
<AdSystem>prebid.org wrapper</AdSystem>\
<VASTAdTagURI><![CDATA[%s]]></VASTAdTagURI>\
<Creatives></Creatives>\
</Wrapper></Ad></VAST>\
""".formatted(bidNurl);
}

private static EventsContext givenEventsContext(boolean accountEnabled) {
Expand Down